Something like this problem might also occur in other cases.
So, for example, you might get "undefined local variable or method
`current_user’ " if you’ve not granted all to your project user during
This may occur inadvertently as you drop test and development database
that have been corrupted and re-“create” them (as in MySQL) but forget
the “grant all” step.
In this case, you see the errors when you try to access the application
through the browser.
Once you do “grant all,” you still see the problem in the browser.
What you need to do after “grant all” is to re-start WEBRick because the
previous DB connection remains with a user with no privileges remains
active until you stop the WEBRick rails container … so to speak.
What do I need to do to be able to use an acts_as_authenticated
current_user in a model?
Is there some sort of include or require I can do some where that would
Here is what I am trying to do:
class Setting < ActiveRecord::Base
before_create :created_by_user # create only
before_save :updated_by_user # both, create and update
self.created_by_user_id = current_user.id
self.created_by_user_login = current_user.login
self.updated_by_user_id = current_user.id
self.updated_by_user_login = current_user.login
But it gives me this error:
undefined local variable or method `current_user’ for