I am still somewhat new to rails and I am not getting the results I am
expecting with my models.. perhapse I do not understand something, or
just didn't set something up right.

I have three models:

class Coordinator < ActiveRecord::Base
        belongs_to :county
        belongs_to :state
end

class State < ActiveRecord::Base
        has_many :counties
        has_many :coordinators, :through => :counties
        accepts_nested_attributes_for :counties, :coordinators
end

class County < ActiveRecord::Base
        belongs_to :state
        has_one :coordinator
        accepts_nested_attributes_for :coordinator
        scope :returncounty, lambda {|state| where(:state_id => state)}
end

When I try and do something like this in my view

<% @states.each do |state| %>
<% state.counties.each do |county| %>
<p><%= county.name %> <%= county.coordinator.name %></p>
<% end %>
<% end %>

I am getting:this error. I have tried several variations on this
theme.. so I feel like I am stuck in my understanding of how rails
associations work. Can someone point me in the right direction?
undefined method `name' for "#<Coordinator:
0x00000003a83128>":Coordinator

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to