On 24 April 2013 10:39, ejo
<ebinjo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have an issue related to rails.
> The class definition is given below.
>
>
> class Supplier < ActiveRecord::Base
> has_one :criteria
You need to specify the foreign key also (crt_sup_id) here as it is
non-standard.
On a side note I strongly recommend using the default id names unless
you absolutely cannot do that. It will make life much easier, as you
have already found.
Colin
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> 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.
>
>
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.