我无法在模板中显示notice
变量。代码如下:
class UserController < ApplicationController
protect_from_forgery
skip_before_filter :require_login, :except=>[:list,:add,:delete,:update]
def add
end
def delete
end
def update
end
def list
end
def login
end
def logout
end
def isloggedin
login = params[:login].to_s
password = params[:password].to_s
logged_in = User.where(:user_name => login,:password => password).limit(1)
if not logged_in.blank?
session[:userinfo] = logged_in
redirect_to '/event/list'
else
flash[:notice] = 'Unable to login'
redirect_to '/user/login'
end
end
end
模板文件
<div><%= notice %></div>
答案 0 :(得分:2)
将其添加到模板文件中:
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %>"><%= value %></div>
<% end %>
因此,当您下次使用&#34替换密码时,请注意&#34; &#34;无法登录&#34;
希望这有帮助! 感谢
答案 1 :(得分:0)
因为我收到错误Can't verify CSRF token authenticity
。我在表单中添加了以下输入字段,它开始显示消息:
<input name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>" />