title: Creating a secure login in ruby on rails
body: <p>I am trying to create a secure login that will require a username and password. I am struggling with this and can not figure out the problem. When I try to access my login page I receive an error for &lt;%= form_tag login_url do %> in the login page. If anyone can help me make this work, you will be my hero.</p>
  
  <p>Schema for table that holds username and password</p>
  
  <pre><code>create_table "users", force: true do |t|
      t.string   "name"
      t.string   "password_digest"
      t.string   "password"
      t.string   "password_confirmation"
      t.datetime "created_at"
      t.datetime "updated_at"
    end
  </code></pre>
  
  <p>Controller from the table that holds username and password </p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_secure_password
  end
  </code></pre>
  
  <p>The login page (which I can not get to work)</p>
  
  <pre><code>&lt;h2&gt;The Maintenance Functions are restricted to authorized users. Please login below&lt;/h2&gt;
  &lt;%= form_tag login_url do %&gt;
    &lt;p&gt;
      &lt;label for="name"&gt;Name:&lt;/label&gt;
      &lt;%= text_field_tag :name, params[:name] %&gt;
    &lt;/p&gt;
    &lt;p&gt;
      &lt;label for="password"&gt;Password:&lt;/label&gt;
      &lt;%= password_field_tag :password, params[:password] %&gt;
    &lt;/p&gt;
    &lt;%= submit_tag "login" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>The controller for the login page</p>
  
  <pre><code>class SessionsController &lt; ApplicationController 
    def new  
    end
  
    def create 
      user = User.find_by_name(params[:name])
  
      if user and user.authenticate(params[:password])
        session[:user_id] = user.id
        redirect_to secertin_secertout_path :notice =&gt; "Logged in successfully"
      else
        flash.alert = "Invalid userid/password combination"
        render 'new' 
      end
    end
  
    def destroy 
      session[:user_id] = nil
      redirect_to root_url_path :notice =&gt; "Logged Out" 
    end
  end
  </code></pre>