Model field accessor missing? Driving me insane

I did a simple migration…

class AddAdminDesignationToUsers < ActiveRecord::Migration
def self.up
add_column :users, :is_admin, :boolean
end

def self.down
remove_column :users, :is_admin
end
end

Now, if I go into the rails console, I can load a user from the DB and I
get correct results… u.is_admin? => false (or whatever).

But if I use ‘is_admin?’ or ‘is_admin’ in a view or the controller
itself, I get an error: ‘undefined method `is_admin?’ for
#User:0x47750ac

Any ideas why? I’ve restarted the server (mogrel), and everything else I
could
think of. Why would that work in the rails console (which uses the same
environment, etc) but not in the app itself?

end
could
think of. Why would that work in the rails console (which uses the same
environment, etc) but not in the app itself?

Perhaps you ran the migration and console in development mode, but your
app is running in production mode so the migration never made it into
the
right database?

?

I actually have them all pointing at the same database. And I also
tried running in development to test it out. Nothing.

Interestingly, the EXACT same app with the exact same migration is
working on my development machine, in both development mode and
production mode.

unsubscribe

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