Forum: Ruby on Rails ActiveRecord Limitation (Advance)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
nigel.bris (Guest)
on 2007-08-02 11:04
(Received via mailing list)
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        |
----------------
Pratik N. (Guest)
on 2007-08-02 14:27
(Received via mailing list)
Form
belongs_to :form_type
has_many :form_type_items, :through => :form_type

On 8/2/07, nigel.bris <removed_email_address@domain.invalid> wrote:
>
>
> | id           |
> | title        |
> ----------------
>
>
> >
>


--
Cheers!
- Pratik
http://m.onkey.org
nigel.bris (Guest)
on 2007-08-03 02:10
(Received via mailing list)
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
Dondi S. (Guest)
on 2007-08-03 02:45
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})
nigel.bris (Guest)
on 2007-08-03 09:50
(Received via mailing list)
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 S. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.