这里是我的控制器代码检查用户的登录信息如何存储find_by_sql_results在会话变量
def validateLogin
@email = params[:userEmail1]
@pass = params[:userPassword1]
if params[:userEmail1] != nil
valid_user = Userprofile.find_by_sql(["select * from userprofiles where userEmail=? and userPassword=?", @email, @pass])
if valid_user.count > 0
session[:email] = @email
session[:uid] = valid_user.id
session[:userType] = valid_user.userType # usertype is a column in userprofiles table
# But here i am not receiving the usertype it gives error that undefined variable usertype.
redirect_to "/userhomes/"
else
flash[:message] = "Either email or password is incorrect"
redirect_to '/'
end
else
flash[:message]="Fields can not be blank"
render :action=>'defaults'
end
请帮
session[:userType] = valid_user.userType
# Error: (usertype is a column in userprofiles table)
但是在这里我无法接收提示错误的用户类型是未定义的变量usertype。