ruby on rails - belongs_to with multiple models -
I am a rail nuke and have a question. I have a feed aggregator that is organized by this general concept:
Feed category (books, electronics, etc.) Feed site section (home page, book page, etc.) Feed (feed themselves) Entry
Such:
class category & lt; ActiveRecord :: Base has has_many: feeds have has_many: feed_entries ,: through = & gt; : Feed, limit = & gt; 5 validates_presence_of: name attr_accessible: name ,: id end class section & lt; ActiveRecord :: Base has has_many: feeds have has_many: feed_entries ,: through = & gt; : Feed, limit = & gt; 5 attr_accessible: name ,: id end class feed & lt; ActiveRecord :: base is_to: categories belong_to: class is_many: feed_entries validates_presence_of: name ,: feed_url attr_accessible: name ,: feed_url ,: category_id ,: section_id end class FeedEntry & lt; ActiveRecord :: Base is_to: feed is_to: range belongs_to: section validates_presence_of: title ,: url end
understand? Now, in my index page, I basically say ... If you are in category books then on the Home page section, give me the feed-class feed entries ...
In my Controller:
def index = part = section.find_bie_name ("home page") @ books = category.find_b_name ("books") end
see me in :
& lt;% = render: partial = & gt; 'Feed_list',: local = & gt; {: Feed_group = & gt; @ Books.feeds} -%>
This will spit the markup for each feed entry in the @Books collection of partial feeds. Now what do I need to do to combine anyway with @books section ...
I tried to do this:
But this section is not limited by ID. I have confirmed section ID using the same code in the console ...
What do you mean? any advice?
Thank you!
Try something like this:
Comments
Post a Comment