Thanks to some help from earlier posters, I''ve been moving along with my test application. I did run into one more stumbling block, though. Say I have two sets of headlines, news and sports, the table structures are slightly different but each has a headline, writer and date. In the controller: @news = News.find(:all) @sports = Sports.find(:all) Getting they to display like this isn''t a problem. News News Headline 1 - Writer 08-01-2008 News Headline 2- Writer 07-31-2008 News Headline 3- Writer 06-05-2008 Sports Sports Headline 1- Writer 07-30-2008 Sports Headline 2- Writer 06-16-2008 My question is this: How do you structure the loop to go through both arrays and display based on date so that the result could be two, intertwined lists. Example: News Headline 1 - Writer 08-01-2008 News Headline 2 - Writer 07-31-2008 Sports Headline 1 - Writer 07-30-2008 Sports Headline 2 - Writer 06-16-2008 News Headline 3 - Writer 06-05-2008 Any help or starting points would be sincerely appreciated. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Elliot Chyba wrote:> > My question is this: > How do you structure the loop to go through both arrays and display > based on date so that the result could be two, intertwined lists. > Example: > > News Headline 1 - Writer 08-01-2008 > News Headline 2 - Writer 07-31-2008 > Sports Headline 1 - Writer 07-30-2008 > Sports Headline 2 - Writer 06-16-2008 > News Headline 3 - Writer 06-05-2008 > > Any help or starting points would be sincerely appreciated.you could use polymorphic associations? http://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html your class definitions might look lke class Article < ActiveRecord::Base belongs_to :content, :polymorphic => end class News < ActiveRecord::Base has_one :article, as => :content end class Sports < ActiveRecord::Base has_one :article, as => :content end Also, refer to Polymorphic Associations section in Chapter 18.4 Joining to Multiple Tables of Agile Web Development with Rails (third edition). If you dont have this book, i HIGHLY recommend you get it from http://www.pragprog.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
aa aa wrote: slight typo, missed the "true> class Article < ActiveRecord::Base > belongs_to :content, :polymorphic => true > end > class News < ActiveRecord::Base > has_one :article, as => :content > end > class Sports < ActiveRecord::Base > has_one :article, as => :content > end-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---