Reputation: 649
I'm working on letting users sign in and out of my rails app. The error I get is as follows
undefined method 'find_by_remember_token'
The method in question is written like this:
def current_user
@current_user ||= User.find_by_remember_token(cookies[:remember_token])
end
Any help you can provide in fixing this error would be greatly appreciated!
Upvotes: 0
Views: 622
Reputation: 4419
you can reset your database and migrate in one line:
rake db:migrate:reset && rake db:migrate && annotate
use the gem annotate in your project to have a better view of your database columns
in your Gemfile add:
gem 'annotate'
and in console run:
bundle update && bundle install
Upvotes: 1
Reputation: 1
I know this is an old question, but I had the same problem and wanted to include how I fixed it.
First, I made sure I added the required info to the migration:
class AddRememberTokenToUsers < ActiveRecord::Migration
def change
add_column :users, :remember_token, :string
add_index :users, :remember_token
end
end
then I just dumped my db and remigrated:
rake db:drop
rake db:create
rake db:migrate
worked for me after that.
Upvotes: 0
Reputation: 27961
You don't have a field in your users
table called remember_token
?
Upvotes: 0