title: Ruby on Rails (Michael Hartl) lesson no. 8 could not login as a user
body: <p>I followed RORT by Michael Hartl( to the letter) lesson 8 upto section 8.2.3 and i could not login as a user. Following is the error log that is generated</p>
  
  <pre><code>--- !ruby/object:ActionController::Parameters
  parameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
    utf8: "✓"
    authenticity_token: ywHzc90gQ54IgmJpt+QdX43MEah/JAoVt93sSOFYAcZ/iVqXEle/eFWBrtDi9AqF77RBIMHYRbUVj87UBrtBHQ==
    session: !ruby/object:ActionController::Parameters
      parameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
        email: monster@railstutorial.org
        password: XXXXXXX
      permitted: false
    commit: Log in
    controller: sessions
    action: create
  permitted: false
  </code></pre>
  
  <p>I am not able to understand what i did wrong</p>
  
  <p>Code app/controllers/sessions_controller.rb</p>
  
  <pre><code>class SessionsController &lt; ApplicationController
    def new
    end
  
    def create
      user=User.find_by(email: params[:session][:email].downcase)
      if user &amp;&amp; user.authenticate(params[:session][:email])
          log_in user
          redirect_to user
          #here
      else
          flash.now[:danger]="Invalid email/password combination"
          render 'new'
      end
    end
  
    def destroy
    end
  
  end
  </code></pre>
  
  <p>Code app/helpers/sessions_helper.rb</p>
  
  <pre><code>module SessionsHelper
  
      def  log_in(user)
          session[:user_id]=user.id
      end
  
      def current_user
          @current_user ||= User.find_by(id: session[:user_id])
          @current_user
      end
  
      def logged_in?
      !current_user.nil?
    end
  
  end
  </code></pre>