On Sep 22, 2008, at 9:54 AM, Becca Girl wrote: > Rob Biedenharn wrote: >> Then you need to give the proper foreign_key >> >> class User >> has_many :reviews, :foreign_key => 'created_by' >> end >> >> class Review >> belongs_to :creator, :class_name => 'User', :foreign_key => >> 'created_by' >> end > > > I must be missing what you're telling me because I get an error. > Polymorphic associations are new to me and quite confusing. I've > read a > lot, but still don't quite understand how to set these up. > > C:/project/vendor/rails/activesupport/lib/active_support/ > dependencies.rb:2 > 15:in `load_without_new_constant_marking': > C:/var/intranet3/app/models/user.rb:1 > 55: parse error, unexpected kEND, expecting $ (SyntaxError) > > > class CreateReviews < ActiveRecord::Migration > def self.up > create_table :reviews missing: do |t| > > t.string :reviewable_type > t.integer :reviewable_id > t.string :title > t.text :body > t.integer :create_review_user_id > t.integer :modify_review_user_id > end > end > end > > > > > class User > has_many :reviews, :foreign_key => 'create_review_user_id' > has_many :reviews, :foreign_key => 'modify_review_user_id' You can't call both associations "reviews" has_many :created_reviews, ... has_many :editted_reviews, ... > > end > > class Review > belongs_to :creator, :class_name => 'User', :foreign_key => > 'create_review_user_id' > belongs_to :modified, :class_name => 'User', :foreign_key => > 'modify_review_user_id' belongs_to :modifier might be a better name than 'modifiED' > > end
-Rob Rob Biedenharn http://agileconsultingllc.com [EMAIL PROTECTED] --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

