rich.pav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Oct-15 06:10 UTC
Very simple code throwing "uninitialized constant" error
This code works on an older version of Ruby and Rails but not with Ruby 1.8.6 and Rails 1.2.5. The code is so simple that I can''t figure out where the problem is. profile_controller.rb class ProfileController < ApplicationController def show @profile = Profile.find_by_school_id(params[:id]) end end ----------------------------------------------------------- profile.rb class Profile < ActiveRecord::Base belongs_to :school belongs_to :profile_type translates :text #<--- I''m using the Globalize plugin end -------------------------------------------------------- http://localhost:3000/en/profile/show/51 throws: NameError in ProfileController#show uninitialized constant Profile RAILS_ROOT: script/../config/.. vendor/rails/activesupport/lib/active_support/dependencies.rb:100:in `const_missing'' vendor/rails/activesupport/lib/active_support/dependencies.rb:131:in `const_missing'' vendor/rails/activesupport/lib/active_support/dependencies.rb:133:in `send'' vendor/rails/activesupport/lib/active_support/dependencies.rb:133:in `const_missing'' app/controllers/profile_controller.rb:4:in `show'' ---------------------------------------------------- If I change the query to @profile = Foobar.find(:first, :conditions => ["school_id = ?", params[:id]]) I get a similar error, but it also adds: This error occured while loading the following files: foobar.rb ...so I assume it knows about the profile.rb model. Why is it saying Profile is an uninitialized constant, and why does this braindead simple code work fine in an older version of Rails but not the latest? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Oct-15 07:17 UTC
Re: Very simple code throwing "uninitialized constant" error
On 15 Oct 2007, at 07:10, rich.pav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > ...so I assume it knows about the profile.rb model. Why is it saying > Profile is an uninitialized constant, and why does this braindead > simple code work fine in an older version of Rails but not the latest? > >I''ve seen ruby 1.8.6 get fussy about line endings in a way that previous versions weren''t. Check all your files use the same. I''d also check that the Globalize plugin is also being loaded properly Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
rich.pav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Oct-15 07:43 UTC
Re: Very simple code throwing "uninitialized constant" error
The globalize plugin appears to be working--I can switch between languages on other pages. But I''m probably using an older version so I''ll try updating it. But even if I comment out the "translates :text" line in the Profile model, I still get the same error. As for line endings, I don''t see any stray tabs, spaces or nonprintable characters. On Oct 15, 4:17 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 15 Oct 2007, at 07:10, rich....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > ...so I assume it knows about the profile.rb model. Why is it saying > > Profile is an uninitialized constant, and why does this braindead > > simple code work fine in an older version of Rails but not the latest? > > I''ve seen ruby 1.8.6 get fussy about line endings in a way that > previous versions weren''t. Check all your files use the same. I''d > also check that the Globalize plugin is also being loaded properly > Fred--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
rich.pav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Oct-15 07:45 UTC
Re: Very simple code throwing "uninitialized constant" error
Since I originally created the application with an older version of Ruby and Rails, do I need to do something to update the application? Some kind of rake command? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Oct-15 07:53 UTC
Re: Very simple code throwing "uninitialized constant" error
On 15 Oct 2007, at 08:43, rich.pav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > The globalize plugin appears to be working--I can switch between > languages on other pages. But I''m probably using an older version so > I''ll try updating it. But even if I comment out the "translates :text" > line in the Profile model, I still get the same error. > > As for line endings, I don''t see any stray tabs, spaces or > nonprintable characters.By line ending problems I mean some a file using dos line endings (on a unix like machine) or vice versa.> > On Oct 15, 4:17 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On 15 Oct 2007, at 07:10, rich....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: >> >>> ...so I assume it knows about the profile.rb model. Why is it saying >>> Profile is an uninitialized constant, and why does this braindead >>> simple code work fine in an older version of Rails but not the >>> latest? >> >> I''ve seen ruby 1.8.6 get fussy about line endings in a way that >> previous versions weren''t. Check all your files use the same. I''d >> also check that the Globalize plugin is also being loaded properly >> Fred > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Oct-15 08:21 UTC
Re: Very simple code throwing "uninitialized constant" error
On 15 Oct 2007, at 08:45, rich.pav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > Since I originally created the application with an older version of > Ruby and Rails, do I need to do something to update the application? > Some kind of rake command?There is rake rails:update which will update boot.rb and various things. Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---