这是我会话的控制器代码
def create
user = User.authenticate(params[:login], params[:password])
if user
session[:user_id] = user.id
redirect_to_target_or_default root_url, :notice => "Logged in successfully."
else
flash.now[:alert] = "Invalid login or password."
render :action => 'new'
end
end
我需要一个id="welcomebuttons"
位于 layouts/application.html.erb 中的 div 以在用户不在会话中(注销)时显示,但在用户登录时完全消失并保持隐藏状态。我尝试添加javascript:hideDiv_welcomebuttons()
到if user
但当然没有不工作。
有人可以帮忙吗?