I have a class (Article) that has a habtm relationship with ''links'', where links are also Articles. I''ve got a join table called articles_links, and have set up the relationship so that it understands what''s going on (i think): 1. class Article < ActiveRecord::Base 2. has_and_belongs_to_many :links, 3. :class_name => "Article", 4. :association_foreign_key => "link_id", 5. :join_table => "articles_links" When i make a new link, using a form, the article is created fine but i can''t work out how to create the join. I''m sure this is simple but i can''t find out how. My ''create link'' method looks like this: 1. def create_link 2. @link = Article.new(params[:article]) 3. #set some attributes of the new object 4. if @link.title == "" 5. @link.title (Hpricot(open(@link.url))/"title").first.inner_html 6. end 7. @link.added_at = DateTime.now.to_s 8. @link.user_id = session[:user].id 9. @link.points = 0 10. #then save it and return to the original article page 11. if @link.save 12. flash[:notice] = ''Link was successfully created.'' 13. redirect_to :action => ''show'', :id => params[:article].id 14. else 15. flash[:warning] = ''Could not create link'' 16. render :action => ''new_link'' 17. end 18. end Can anyone explain to me how to set up the join properly? -- 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 -~----------~----~----~----~------~----~------~--~---