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? -- 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 -~----------~----~----~----~------~----~------~--~---
It would be better if you explained what X and Y were and how they relate to each other. Could you please do that for us? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> It would be better if you explained what X and Y were and how they > relate to each other. Could you please do that for us? Thanks.It''s fixed :) Thanks. -- 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 -~----------~----~----~----~------~----~------~--~---
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 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 -~----------~----~----~----~------~----~------~--~---
Well don''t leave us hanging--how''d you fix it? ;-) -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk@googlegroups.com] On Behalf Of Jamal Soueidan Sent: Thursday, October 30, 2008 7:35 AM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: X is not missing constant Y Ryan Bigg wrote:> It would be better if you explained what X and Y were and how they > relate to each other. Could you please do that for us? Thanks.It''s fixed :) Thanks. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Roy Pardee wrote:> Well don''t leave us hanging--how''d you fix it? ;-)Oh I thought I''d explained it in the previous message. I took the class definitions out of the module, and moved them into the rake file. That did the trick. I suspect that the problem has something to do with the associations being to ActiveRecords that are declared inside modules and then used outside those modules. But I''ve not had a chance to play around to find out. 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 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 -~----------~----~----~----~------~----~------~--~---
On Oct 30, 7:08 pm, John Small <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Roy Pardee wrote: > > Well don''t leave us hanging--how''d you fix it? ;-) > > Oh I thought I''d explained it in the previous message. I took the class > definitions out of the module, and moved them into the rake file. That > did the trick. >If you were previously using require to require files in your app then that can screw things up big time. Fred> I suspect that the problem has something to do with the associations > being to ActiveRecords that are declared inside modules and then used > outside those modules. But I''ve not had a chance to play around to find > out. > > John Small > > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> If you were previously using require to require files in your app then > that can screw things up big time. > > FredA very mysterious clue! How would require mess things up? This is something we all need to know. I certainly do, it''s quite hard for me to find out about all the little hidden undocumented tricks that one needs to know to become a true pro. 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 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 -~----------~----~----~----~------~----~------~--~---
Roy Pardee wrote:> Well don''t leave us hanging--how''d you fix it? ;-)Sorry, I went home from work before but now I''m online again. class Blog::Post < ActiveRecord::Base belongs_to :category end class Blog::Category < ActiveRecord::Base has_many :posts end Error: Blog is not missing constant Post so I just did this :) class Blog::Post < ActiveRecord::Base belongs_to :category, :class_name => "Blog::Category", :foreign_key => :category_id end class Blog::Category < ActiveRecord::Base has_many :posts, :class_name => "Blog::Post", :foreign_key => :category_id end and then it works :) -- 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 -~----------~----~----~----~------~----~------~--~---
On Oct 30, 8:01 pm, John Small <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > If you were previously using require to require files in your app then > > that can screw things up big time. > > > Fred > > A very mysterious clue! How would require mess things up? This is > something we all need to know. I certainly do, it''s quite hard for me to > find out about all the little hidden undocumented tricks that one needs > to know to become a true pro.Short version: because requiring files that could be loaded by rails'' dependency system confuses said system (in development mode) long version: http://www.spacevatican.org/2008/9/28/required-or-not Fred> > Cheers > > John Small > > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---