Friday, August 27, 2010

[Rails] Linking Models

Hi...

I'm just starting with Rails 3.0.0.rc and am trying to get my models
to link as I did in previous rails releases...

I.e...

I used to be able to tell the model:
belongs_to :districts

then in the controller:
def index
@districts = District.find(:all)
@provers = Prover.find(:all)
...
end

then in the view have a line like:
<% @provers.each do |prover| %>
<%= prover.district.name %>
....

I'm expecting this to join the provers and districts tables so I can
return the district name instead of it's foreign key id...!

At any rate, in rails 3 this no longer works...

--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate