dimanche 14 octobre 2018

Ruby on Rails - user session login

I'm getting syntax error, unexpected '=', expecting keyword_end (session [:user_id]) = user.id ^ and syntax error, unexpected '=', expecting keyword_end session [:user_id] = user.id

 class SessionsController < ApplicationController
      def new
      end

      def create
          user = User.find_by(email: params[:session][:email])
          if user && user.authenticate(params[:session][:password])

              session [:user_id] = user.id
              redirect_to user
           else
              flash.now[:error] = 'Bad email/pwd combo. do again'
              render 'new'

           end 


       end

       def destroy
           session.delete(:user_id)
           @current_user = nil
           redirect_to site_home_path
        end 
end

Aucun commentaire:

Enregistrer un commentaire