Jamal Soueidan wrote:
> Moving my app from rails 1.2 to rails 2.1, I stuck into this weird
> problem?
>
> X is not missing constant Y.
>
> The problem occurs when I use the join table association.
>
> X.find(1).y
>
> It works in (script/console) but not in browser?
>
> Anyone have any experience with this issue?
Yes! and the really bizarre part of the problem is that the same Rails
version worked OK in WinXP
My problem appeared when I had the following in let's say
legacy_data_models.rb
module LegacyDataBaseStuff
$olddb = {some_db_options}
Class OldParentItem < ActiveRecord::Base
has_many :old_child_items
establish_connection $olddb
end
Class OldChildItem < ActiveRecord::Base
belongs_to :old_parent_item
establish_connection $olddb
end
end
Then in a rake task to import things from a legacy database I'd open a
parent like so
parent = LegacyDataBaseStuff::OldParentItem.find :all
which works until I'd try
parent.old_child_items
which would give me exactly the error you're getting "X is not missing
constant Y"
I worked around the problem by taking the models out of the module and
just putting everything in the rake file. Not clean but it did the job
and the job only needed to be done once.
I'd be interested to know how your situation compares
Cheers
John Small
--
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---