This is my session’s controller code
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
I need a div id="welcomebuttons" located in layouts/application.html.erb to display when the user is not in session (logged out) but disappear completely and remain hidden when the user is logged in. I tried adding javascript:hideDiv_welcomebuttons() to the if user but of course that didn’t work.
Could anyone help?
in application layout