Multiple belongs_to a single model

i came across this post by s.ross and i am having a similar problem.
but mine is related to output.

<http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/
3f3a0f4b1e8ab157/e5d055c888a155da?lnk=gst&q=multiple
+belongs_to#e5d055c888a155da>

in his example his he has multiple associations

 class Bug < ActiveRecord::Base
    belongs_to :reporter, :class_name=>'User', :foreign_key =>

‘reporter_id’
belongs_to :assignee, :class_name=>‘User’, :foreign_key =>
‘assigned_to_id’

everything works great, in console but in the app.

@bugs = Bug.find :all
for errors in @bugs
errors.date - no problem works fine
errors.reporter.name - gets an error
errors[45].reporter.name - works fine

what am i doing wrong

this works in console
ie:

@bugs = Bug.find :all
one_error = @bugs[45]
one_error.date (good)
one_error.reporter.name (good)
one_error.assignee.name (good)

it has to be something simple. tia

does anyone have an idea on this.

i have check all the capitalization

variable.association.assocation_variable

i really need some pointers on this.

Can you give us a concrete version of it, rather than this abstract
version?

Julian.

Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) VIDEO #3
OUT APRIL 6
http://sensei.zenunit.com/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs