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 completed successfully, flash is installed and redirects to the first page. This part works. The second part does not set the flash notification message. Then, when the page is displayed, the flash message is not displayed. What else i try to have
return redirect_to root_url
but still nothing shows. In my controller, I have a helper such as flash_notice, all it does is return flash [: notice]. This is due to the fact that the flash is always empty in the view, but available in the controller. In the view, I have only one line:
<%= flash_notice %>
I use rails 3.1
source
share