Ruby on Rails Wednesday, April 24, 2013

I have an issue related to rails.
The class definition is given below.


    class Supplier < ActiveRecord::Base 
      has_one :criteria 
      self.primary_key = 'sup_id' 
    end 

    class Criteria < ActiveRecord::Base 
      belongs_to :supplier, :foreign_key => "crt_sup_id" 
      self.primary_key = 'crt_id' 
      self.table_name = 'criterias' 
    end 


If I am using self.supplier in class Criteria it is working fine

but If I am using self.criteria in class Supplier then error thrown as,


Unknown column 'criteria.supplier_id' in 'where clause': SELECT  `criteria`.* FROM `criteria`  WHERE `criteria`.`supplier_id`

I don't have a field named supplier_id in criteria instead I am using crt_sup_id as defined in the class.


Please help on this.


Thanks.

--
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+unsubscribe@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/msg/rubyonrails-talk/-/i3p0RDGyaQkJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment