Hi. Currently, I had 2 models linked with HABTM association: _Article_ and _Tag_ class Article < ActiveRecord::Base has_and_belongs_to_many :tags end class Tag < ActiveRecord::Base has_and_belongs_to_many :articles end But I believe I need to ad another model called _User_. Do you know how processed to get a HABTM association with: _Article_, _Tag_ and _User_? Thx -- 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 -~----------~----~----~----~------~----~------~--~---
just an information to be more clear: I had yet created a table called "articles_tags_users" in the database. -- 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 -~----------~----~----~----~------~----~------~--~---
Am 24.10.2008 um 16:23 schrieb Panda Beer:> > just an information to be more clear: > I had yet created a table called "articles_tags_users" in the > database.I think you are looking for something like this: http://agilewebdevelopment.com/plugins/acts_as_taggable_on_steroids -- Jochen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jochen Kaechelin wrote:> I think you are looking for something like this: > http://agilewebdevelopment.com/plugins/acts_as_taggable_on_steroidsI think this solution is a little bit so specific and so complexe for my association need. I hope there is a more simple way include by defaut in ActiveRecord. Mark Reginald James wrote:> Perhaps by creating a Hub model with three foreign keys, and > using has_many through.In my context, I prefer using only 3 models with a HABTM association rather than using 4 models with some has_many through. Thanks for your ideas. -- 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 -~----------~----~----~----~------~----~------~--~---
YES! I found the answer: class Article < ActiveRecord::Base has_and_belongs_to_many :tags, :join_table => :articles_tags_users has_and_belongs_to_many :users, :join_table => :articles_tags_users end class Tag < ActiveRecord::Base has_and_belongs_to_many :articles, :join_table => :articles_tags_users has_and_belongs_to_many :users, :join_table => :articles_tags_users end class User < ActiveRecord::Base has_and_belongs_to_many :articles, :join_table => :articles_tags_users has_and_belongs_to_many :tags, :join_table => :articles_tags_users end have fun! -- 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 -~----------~----~----~----~------~----~------~--~---
Some help please! How do you fill the table with the three foreign keys?? i put user = User.new tag = Tag.find(id) article = Article.find(id) user.tag << tag user.article << article user.save all this creates 2 tuples on the database articles_tags_users instead of one with all the values On Sat, Oct 25, 2008 at 6:02 AM, Panda Beer < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > YES! I found the answer: > > class Article < ActiveRecord::Base > has_and_belongs_to_many :tags, :join_table => :articles_tags_users > has_and_belongs_to_many :users, :join_table => :articles_tags_users > end > > class Tag < ActiveRecord::Base > has_and_belongs_to_many :articles, :join_table => :articles_tags_users > has_and_belongs_to_many :users, :join_table => :articles_tags_users > end > > class User < ActiveRecord::Base > has_and_belongs_to_many :articles, :join_table => :articles_tags_users > has_and_belongs_to_many :tags, :join_table => :articles_tags_users > end > > have fun! > -- > Posted via http://www.ruby-forum.com/. > > > >-- Felipe Vergara Contesse IngenierĂa Civil Industrial UC --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---