Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 4021 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

  def self.down
    remove_column :users, :is_admin

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
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!