Or is it ? Need to be able to :- @search Form.find(:all, :include=>[:form_type, :form_type_items], :conditions=>....) I need in the Form model a :form_type_items, the question is, what is the relationship type? Current Models:- Form belongs_to :form_type FormType has_many :form_types has_many :form_type_items FormTypeItem Belongs_to :form_type Form ---------------- | id | ---------------- |form_type_id | ---------------- FormType ---------------- | id | ---------------- | name | ---------------- FormTypeItem ---------------- | id | ---------------- | form_type_id | ---------------- | title | ---------------- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Form belongs_to :form_type has_many :form_type_items, :through => :form_type On 8/2/07, nigel.bris <nigel.bris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Or is it ? > > Need to be able to :- > > @search > Form.find(:all, :include=>[:form_type, :form_type_items], :conditions=>....) > > I need in the Form model a :form_type_items, the question is, what is > the relationship type? > > Current Models:- > Form > belongs_to :form_type > > FormType > has_many :form_types > has_many :form_type_items > > FormTypeItem > Belongs_to :form_type > > > Form > ---------------- > | id | > ---------------- > |form_type_id | > ---------------- > > FormType > ---------------- > | id | > ---------------- > | name | > ---------------- > > FormTypeItem > ---------------- > | id | > ---------------- > | form_type_id | > ---------------- > | title | > ---------------- > > > > >-- Cheers! - Pratik http://m.onkey.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Unfortunately, that code fails with:- Mysql::Error: #42S22Unknown column ''form_types.form_type_id'' in ''on clause'' as this is not a:- pk<-(fk/fk)->pk relationship. its a fk->(pk)<-fk, any ideas what the relationship type is in that case? Thanks On Aug 2, 8:26 pm, Pratik <pratikn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Form > belongs_to :form_type > has_many :form_type_items, :through => :form_type > > On 8/2/07, nigel.bris <nigel.b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Or is it ? > > > Need to be able to :- > > > @search > > Form.find(:all, :include=>[:form_type, :form_type_items], :conditions=>....) > > > I need in the Form model a :form_type_items, the question is, what is > > the relationship type? > > > Current Models:- > > Form > > belongs_to :form_type > > > FormType > > has_many :form_types > > has_many :form_type_items > > > FormTypeItem > > Belongs_to :form_type > > > Form > > ---------------- > > | id | > > ---------------- > > |form_type_id | > > ---------------- > > > FormType > > ---------------- > > | id | > > ---------------- > > | name | > > ---------------- > > > FormTypeItem > > ---------------- > > | id | > > ---------------- > > | form_type_id | > > ---------------- > > | title | > > ---------------- > > -- > Cheers! > - Pratikhttp://m.onkey.org--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
nigel.bris wrote:> Need to be able to :- > > @search > Form.find(:all, :include=>[:form_type, :form_type_items], > :conditions=>....) >What error message do you get with that? Try it with hash (worked for me): Form.find(:all, :include => {:form_type => :form_type_items}) -- 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 -~----------~----~----~----~------~----~------~--~---
Worked Perfectly! You guys are guru''s..... Ps.. Didn''t know that hash inside include feature, rails amazes me more everyday! Thanks! On Aug 3, 8:45 am, Dondi Stroma <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> nigel.bris wrote: > > Need to be able to :- > > > @search > > Form.find(:all, :include=>[:form_type, :form_type_items], > > :conditions=>....) > > What error message do you get with that? Try it with hash (worked for > me): > Form.find(:all, :include => {:form_type => :form_type_items}) > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---