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?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2007-Sep-20 19:19 UTC
Re: 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?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? ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---