我想在登录表单中执行此操作,
我只想在用户提交数据时保留数据,但这是无效的。
下面的代码:
在控制器中:
def login
if request.request_method == "POST"
@session = params[:session]
end
render "login",
:layout => "admin_login"
end
和admin_login
模板:
= form_for :session, :url => { :action => "login", :controller => "administrator" }, :html => { :class => "form-horizontal" } do |f|
%div.control-group
#{f.label :token, "User / Email", :class => "control-label" }
%div.controls
#{f.text_field :token}
%div.control-group
#{f.label :password, "Password", :class => "control-label" }
%div.controls
#{f.password_field :password}
但是当我提交表单时它会抛出异常,说undefined method 'token'
谢谢