find :all :include broken on Oracle 10

Hi,

I am trying the following in Ruby using InstantRails 1.7 on WindowsXP

Publication.find(:all, :include => [:doc_type, :release_state] )

but I get the error:

OCIError: ORA-00904: "DOC_TYPES"."PUBLICATION_ID": invalid identifier: SELECT publications.id AS t0_r0, publications.docid AS t0_r1, publications.doc_type_id AS t0_r2, publications.title AS t0_r3, publications.lang AS t0_r4, publications.keywords AS t0_r5, publications.cvsdir AS t0_r6, publications.publishername AS t0_r7, publications.publisherorg AS t0_r8, publications.release_state_id AS t0_r9, doc_types.id AS t1_r0, doc_types.code AS t1_r1, doc_types.en AS t1_r2, doc_types.es AS t1_r3, doc_types.sv AS t1_r4, doc_types.descr AS t1_r5, release_states.id AS t2_r0, release_states.code AS t2_r1, release_states.name AS t2_r2, release_states.descr AS t2_r3 FROM publications LEFT OUTER JOIN doc_types ON doc_types.publication_id = publications.id LEFT OUTER JOIN release_states ON release_states.publication_id = publications.id

Obviously, the joins should be:

LEFT OUTER JOIN doc_types ON doc_types.id = publications.doc_type_id LEFT OUTER JOIN release_states ON release_states.id = publications.release_state_id

Here is the model:

class Publication < ActiveRecord::Base   has_many :pub_editions   has_one :doc_type   has_one :release_state end

What's the problem?

Much appreciated, Kevin

you're specifying in the wrong way the associations.

You need to read the docs about the differences among has_one and belongs_to Probably your model should be more like

class Publication < ActiveRecord::Base has_many :pub_editions belongs_to :doc_type belongs_to :release_state end

Paolo

Hi Kevin,

I am trying the following in Ruby using InstantRails 1.7 on WindowsXP

Publication.find(:all, :include => [:doc_type, :release_state] )

but I get the error:

[...]

What's the problem?

Please use the rubyonrails-talk list for support and troubleshooting. The core list is for discussion of Rails internals and implementation.

Thanks, jeremy