undefined method `activated?'

1.6k Views Asked by At

I'm trying to implement Authlogic in Rails 3 and have just been having headache after headache...I'm extremely new to rails, so please forgive me for not being an expert. I followed the railscast on the subject which has been really helpful, but as soon as i submit my create new user form via the actual website I get this:

undefined method `activated?'

app/controllers/users_controller.rb:37:in `create'

Any help would be SO appreciated...had a headache with this tonight...

Code from create method:

  def create
    @user = User.new(params[:user])
    if @user.save
      flash[:notice] = "Registration successful."
    else
      render :action => 'new'
    end
  end
2

There are 2 best solutions below

2
On BEST ANSWER

If anyone else hits this issue - regenerate your user_session model and fill it with:

class UserSession < Authlogic::Session::Base 
  def to_key 
    new_record? ? nil : [ self.send(self.class.primary_key) ] 
  end 
end

This fixed it for me...seems to be an error surrounding that model at the very least so take it back to basics!

0
On

The problem for me was the existence of a user_sessions table. If you created the UserSession model through a generator, you have a migration that creates that table.

Simply deleting the table (both in test and development databases) and the migration file solved the problem for me.

Cheers,

-- José