Sign in to follow this  

[web] Rails: Column accessor not defined, but works in console...

This topic is 3739 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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, 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?

Share this post


Link to post
Share on other sites

This topic is 3739 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this