Chris
2009-Jun-03 23:55 UTC
Error loading fixture with serialized field - undefined method `key?''
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
end
and I''m trying to create some test fixtures for this model:
usersiteadmin:
id: 2
login: usersiteadmin
password_salt: <%= salt = User.unique_token %>
crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt
("usersiteadmin" + salt) %>
persistence_token:
6cde0674657a8a313ce952df979de2830309aa4c11ca65805dd00bfdc65dbcc2f5e36718660a1d2e68c1a08c276d996763985d2f06fd3d076eb7bc4d97b1e317
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
email: me-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
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
loading:
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
explicitly:
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
Frederick Cheung
2009-Jun-04 07:42 UTC
Re: Error loading fixture with serialized field - undefined method `key?''
On Jun 4, 12:55 am, Chris <csw11...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> However, when I try to rake I get this error when the fixtures are > loading: > 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 > explicitly: > 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. ThanksYou might want to stick quotes around that string to stop yaml parsing it Fred> > -Chris W
Chris Warren
2009-Jun-05 23:26 UTC
Re: Error loading fixture with serialized field - undefined method `key?''
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 Cheung<frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Jun 4, 12:55 am, Chris <csw11...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> However, when I try to rake I get this error when the fixtures are >> loading: >> 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 >> explicitly: >> 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 > > You might want to stick quotes around that string to stop yaml parsing > it > > Fred >> >> -Chris W > > >