I have this code :
def create
login(params[:email], params[:password])
if current_user
flash[:notice] = "Welcome back #{current_user.email}"
return redirect_to_first_page
else
flash[:notice] = "Email or password is wrong. Try again !"
redirect_to root_url
end
end
when the login is successful the flash is set and the redirect to the first page is made. This part is working. The second part is not setting the flash notice message. Then when the page is displayed no message from flash is show. What is different i've try to have
return redirect_to root_url
but nothing still not showing anything. In my controller i have a helper like flash_notice all it does is return flash[:notice]. This is because the flash is always empty in a view but accessible in controller. In the view i have just one line :
<%= flash_notice %>
I'm using rails 3.1
redirect_to root_url, :notice => "Email or password is wrong. Try again !"work ? - Zabbanoticeinstead offlash_notice- Hockflash_noticeis a method on the controller defined by the OP - Zabbaflash[:notice]directly in the view? Try printing out theflashat various stages in relevant controllers and views. - Zabba