Jump to content
  • Advertisement
Sign in to follow this  
smitty1276

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

This topic is 4102 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!