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:inconst_missing’
vendor/rails/activesupport/lib/active_support/dependencies.rb:133:in
send' vendor/rails/activesupport/lib/active_support/dependencies.rb:133:inconst_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?

On 15 Oct 2007, at 07:10, [email protected] 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

On 15 Oct 2007, at 08:43, [email protected] 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.

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 C. [email protected]

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?

On 15 Oct 2007, at 08:45, [email protected] 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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs