What is Hash Table, how to create a hash table?

Why am I getting a "could not find table" error?

  • I'm relatively new to Rails and I've been getting the above error whenever I'm testing my login page. Here's the test view file:     <%= form_for :user, :url => create_path do |f| %>       <p> Email: <br />  <%= f.text_field :email %></p>       <p> Password: <br />  <%= f.password_field :password %></p>       <p><%= submit_tag "Sign In", :disable_with => "Please wait...", :class => "btn primary" %></p>     <% end %> Here's the Users controller:     class UsersController < ApplicationController         before_filter :get_user, :except => [:register, :login, :create]       before_filter :user_signed_in?, :only => [:delete]       def create         if user = User.find_by_email(params[:user][:email]).try(:authenticate, params[:user][:password])           session[:user_id] = http://user.id           redirect_to root_path # Or whatever you want i.e. redirect_to user         else           render :new, :flash => { :error => "Bad email/password combination" }         end       end       def delete         session.delete(:user_id)       end       def register         if Invite.find_by_hash(params[:hash]).blank?           redirect_to root_path           return         end         @user = User.new(params[:user])         if(request.post? and @user.save)           flash[:notice] = "Account Created Successfully"           redirect_to root_path                return         else           flash.now[:warning] = @user.errors.full_messages         end       end       def destroy         @user = User.find(params[:id])         @user.destroy         redirect_to root_path       end       def login       end       def get_user         @user = User.find(params[:id])       end     end And my User model:     class User < ActiveRecord::Base       has_secure_password       validates :email, :presence => true, :uniqueness => true, :length => {:minimum => 6}       validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i       validates :name, :presence => true, :length => {:maximum => 32}       validates :password, :presence => true, :length => {:minimum => 8}       validates :username, :presence => true, :length => {:maximum => 20}, :uniqueness => true       validates :blog, :uniqueness => true       has_many :posts     end The exact error I'm getting is this: ActiveRecord::StatementInvalid in UsersController#create     Could not find table 'users' And my shema.rb : ActiveRecord::Schema.define(:version => 0) do   create_table "invites", :force => true do |t|     t.integer "user_id", :null => false     t.string  "email"     t.string  "hash",    :null => false     t.boolean "used",    :null => false   end   create_table "posts", :force => true do |t|     t.string   "title",        :limit => 100, :null => false     t.text     "body",                        :null => false     t.datetime "date_created",                :null => false     t.integer  "user_id",                     :null => false   end   create_table "users", :force => true do |t|     t.string "email",                         :null => false     t.string "username",        :limit => 20, :null => false     t.string "blog",                          :null => false     t.string "name"     t.string "password"     t.string "password_digest",               :null => false   end end P.S.: I'm running Rails 3.1.0.rc8. Any help would be appreciated. Thanks. I can't seem to find any table (not just the users table) . I just upgraded to Rails 3.1, everything was fine before that. I ran db:create and db:migrate too, so that's not the problem.

  • Answer:

    Have you created the User model and migrated the db? It may be easiest to put your code somewhere online (like Github) and post a link to it so we have full context of the app.

Glenn Goodrich at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.