Hello,

I just ran into a strange error. In console I typed in following:
ruby-1.9.2-p290 :120 > User.first.to_json
User Load (0.7ms) SELECT `users`.* FROM `users` LIMIT 1
=>
"{\"avatar_id\":10,\"email\":\"peter@example.org\",\"firstname\":\"Peter\",\"lastname\":\"L\",\"user_role_id\":11}"

and when I try that with an avatar:
ruby-1.9.2-p290 :121 > Avatar.first.to_json
Avatar Load (0.5ms) SELECT `avatars`.* FROM `avatars` LIMIT 1
NoMethodError: Attribute Load (0.8ms) SELECT `attributes`.* FROM
`attributes` WHERE `attributes`.`avatar_id` = 10
undefined method `keys' for #<ActiveRecord::Relation:0x007fb6a3e69518>

Why on earth can I convert the user model to json but not the avatar?!

Any suggestions appreciated!
Hans

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 5 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedOct 5, '11 at 3:00p
activeOct 5, '11 at 3:37p
posts5
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Heinz Strunk: 3 posts Colin Law: 2 posts

People

Translate

site design / logo © 2021 Grokbase