You have to use sessions
instead of session
i.e. Use
params[:sessions][:email]
instead of
params[:session][:email]
As your form says sessions
i.e. simple_form_for :sessions
.
But in controller you are accessing params[:sessions]
which is nil
and then calling [:email]
on it hence it is giving error
undefined method '[]' for nil:NilClass
hence change
user = User.find_by_email(params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
To
user = User.find_by_email(params[:sessions][:email].downcase)
if user && user.authenticate(params[:sessions][:password])
and then it should work