Tuesday, June 21, 2011

Re: [Rails] Error of undefined method

Hi,

Few things here:
1. Would be good if you can paste full code from the beginning of the loop till the place where you render picture
2. It is not a good practice to set instance variables in the views, set them in controller instead
3. It is not a good practice to do finds in views, if you want to fetch a picture for the user, it's better to define a relationship between picture and user models. And then do something like this in the controller - @users = User.includes(:picture).all

Hope this helps.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/zIp7YSc9B_MJ.
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate