Forum: Ruby on Rails Error loading fixture with serialized field - undefined method `key?'

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
D74cc7f3b588c1933e5417b99bb1ed59?d=identicon&s=25 Chris (Guest)
on 2009-06-04 01:56
(Received via mailing list)
Hi all,

I'm hoping some kind person out there can help me understand what I'm
doing wrong....

I have a user model, which has two serialized fields-
class User < ActiveRecord::Base
  acts_as_authentic :validate_email_field => false

  has_many :user_domain_roles

  serialize :admin_domains
  serialize :manage_domains

and I'm trying to create some test fixtures for this model:
  id: 2
  login: usersiteadmin
  password_salt: <%= salt = User.unique_token %>
  crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt
("usersiteadmin" + salt) %>
  login_count: 1
  last_request_at: 2009-03-09 19:56:38
  last_login_at: 2009-03-09 19:56:38
  current_login_at: 2009-03-09 19:56:38
  last_login_ip: MyString
  current_login_ip: MyString
  first_name: usersiteadminfname
  last_name: usersiteadminlname
  admin_domains: <%= [1,3,8,2,9,10,11,7].to_yaml %>
  manage_domains: --- []

However, when I try to rake I get this error when the fixtures are
NoMethodError: undefined method `key?' for [1, 3, 8, 2, 9, 10, 11,
{"7\nmanage_domains"=>"--- []"}]:Array

I get the exact same error when I try to generate the string
  admin_domains: <%= "--- \n- 1\n- 3\n- 8\n- 2\n- 9\n- 10\n- 11\n- 7"

I have no idea why it doesn't like my fixture and would really
appreciate any pointers on the matter. Thanks

  -Chris W
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-06-04 09:43
(Received via mailing list)
On Jun 4, 12:55 am, Chris <> wrote:

> I have no idea why it doesn't like my fixture and would really
> appreciate any pointers on the matter. Thanks

You might want to stick quotes around that string to stop yaml parsing

D74cc7f3b588c1933e5417b99bb1ed59?d=identicon&s=25 Chris Warren (Guest)
on 2009-06-06 01:26
(Received via mailing list)
Hi Fred,

Yup - quotes did the trick! In hindsight that makes perfect sense, but
it would have taken me a long time to figure it out on my own.

Much thanks!

  -Chris W

On Thu, Jun 4, 2009 at 3:42 AM, Frederick
This topic is locked and can not be replied to.