我正在尝试使用 ruby on rails 设置登录/会话,但是当我尝试呈现登录页面时出现此错误:
/Users/farhadam/mboddy/app/controllers/sessions_controller.rb:10:语法错误,意外的 tLBRACK,需要关键字_do 或 '{' 或 '(' 参数 [:session][:password] ^ /Users/farhadam/mboddy/ app/controllers/sessions_controller.rb:11:语法错误,意外')',期待keyword_end
这是我的会话控制器:
class SessionsController < ApplicationController
def new
end
def create
user = User.validate_login (
params [:session][:email],
params [:session][:password]
)
if User
sessions[:user_id] = user.id
redirect_to login_path
else
flash[:status] = FALSE
flash[:alert] = 'Invalid username and password!'
redirect_to login_path
end
end
def destroy
session[:user_id] = nil
redirect_to login_path
end
end