On 12 May 2016 at 19:28, Luis <luismcdoug...@gmail.com> wrote: > I am trying to establish the following relation, but no joy! > > Can someone please tell me how should I do this. > Thanks. > Luis > #Sched attributes: > #id > #... > # pcp_id :integer > # admitingMd_id :integer > > > class Sched < ActiveRecord::Base > belongs_to :admitingMd, :class_name => "Pcp", :foreign_key => > ":admitingMd_id" > > #PCP attributes > #id > #... > class Pcp < ActiveRecord::Base > has_many :scheds > has_many :admitingMd, :primary_key => "admitingMd_id", :foreing_key => > "admitingMd_id", :class_name => "Sched" > > > ArgumentError - Unknown key: :foreing_key. Valid keys are: :class_name, > :anonymous_class, :foreign_key, :validate, :autosave, :table_name, > :before_add, :after_add, :before_remove, :after_remove, :extend, > :primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, > :counter_cache, :join_table, :foreign_type:
The clue is in the error message: Unknown key: :foreing_key Which is how you have spelt it in the has_many line. It should be foreign_key of course. In addition I strongly suggest you stick to the rails conventions for naming things. So you should not use a name like admitingMd. It should be belongs_to :admiting_md and has_many admitting_mds (note the plural for has-many). The key should be admiting_md_id. Are you sure you don't mean admitting_md? Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLu%3DdG5VZG6F3%2BCc%2BF7KWm2CSZZAHGQiJCRnaYmoBVJVbw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.