All,
How can I show record association in the "view" part of the MVC using Rails? Ex. I have a class for Building
which would have many apartments
each with a single unique apartment number.
Since I am new to Rails, I wanted t开发者_StackOverflow中文版o understand what is generally the UI structure to represent such associations on the UI side.
I am still not clear, this is how your models would look
class Apartment < ActiveRecord::Base
belongs_to :building
end
class Building < ActiveRecord::Base
has_many :apartments
end
In your routes.rb you may want to have the following
resources :building do
resources :apartments
end
精彩评论