# Model field accessor missing? Driving me insane

**URL:** <https://www.ruby-forum.com/t/model-field-accessor-missing-driving-me-insane/115126>\
**Category:** Rails\
**Created:** [September 20, 2007, 8:55pm UTC](https://www.ruby-forum.com/t/model-field-accessor-missing-driving-me-insane/115126 "2007-09-20T20:55:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dnstevenson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8dc957/32.png) [@dnstevenson](https://www.ruby-forum.com/u/dnstevenson)\
**Post date:** [September 20, 2007, 8:55pm UTC](https://www.ruby-forum.com/t/model-field-accessor-missing-driving-me-insane/115126/1 "2007-09-20T20:55:37Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dnstevenson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8dc957/32.png) [@dnstevenson](https://www.ruby-forum.com/u/dnstevenson)\
**Post date:** [September 20, 2007, 9:04pm UTC](https://www.ruby-forum.com/t/model-field-accessor-missing-driving-me-insane/115126/2 "2007-09-20T21:04:24Z")

</div>

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

?

---

<div class="post-metadata">

**Author:** ![dnstevenson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8dc957/32.png) [@dnstevenson](https://www.ruby-forum.com/u/dnstevenson)\
**Post date:** [September 20, 2007, 9:11pm UTC](https://www.ruby-forum.com/t/model-field-accessor-missing-driving-me-insane/115126/3 "2007-09-20T21:11:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dnstevenson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8dc957/32.png) [@dnstevenson](https://www.ruby-forum.com/u/dnstevenson)\
**Post date:** [September 21, 2007, 3:55pm UTC](https://www.ruby-forum.com/t/model-field-accessor-missing-driving-me-insane/115126/4 "2007-09-21T15:55:58Z")

</div>

unsubscribe
