eld
eld

Reputation: 1

Ruby on rails, table not found

So, quite new to Ruby, and trying to construct my first app. So far, gone well, but i recently had to reclone into it, and now that I try to log in, I keep getting an error, "ActiveRecord::StatementInvalid in SessionsController#create

Could not find table 'users'". I checked the db and the table is there, I know it used to work and cant think why it's not working now. The error message is referring to to files, the session controller which has this bit to create session:

def create
  @user = User.authenticate(params[:email], params[:password])
  if @user
    session[:user_id] = @user.id
    redirect_to root_url, :notice => "Inloggad!"
    session[:user] = @user
  else
    flash.now.alert = "losenord eller email stamde inte overens..."
    render "new"
  end
end

and this bit in the user model:

def self.authenticate(email, password)
  @user = find_by_email(email)
  if @user && @user.password_hash == BCrypt::Engine.hash_secret(password, user.password_salt)
    @user
  else
    nil
  end
end 

Anyone with an inkling as to what could be the problem? Sorry if this is really dumb, as I am only just starting out and am not a brilliant programmer...

Upvotes: 0

Views: 775

Answers (1)

clyfe
clyfe

Reputation: 23770

Run the migrations (and seeds if any):

rake db:migrate db:seed

Upvotes: 3

Related Questions