I have the following code snippet in the controller
def create @message = Message.new(params[:message]) @message.message = h(@message.message) if @message.save flash[:message] = "Message Sent. Thank You for Contacting Me" else flash[:message] = "OOps Something went wrong" end redirect_to :action => 'contact' end
When I try to display a flash message in the form of a contact, it does not appear. I was looking for possible solutions, but they don't seem to work. Any ideas what is going wrong?
Your controller is redirected to: action => 'contact'. Verify that the flash output is output for the template displayed for this action.
<%= flash[:message] %>
Alternatively, you can use render: action ... vs redirect_to: action ... Save the request.
- , . [: ] . -, <%= flash[:notice]%> .
<%= flash[:notice]%>
[: ] . , <%= flash[:message]%> -.
<%= flash[:message]%>
flash[:message] flash[:notice] <%= flash[:message]%> , .
flash[:message]
flash[:notice]
, , , -
<% if flash[:messsage].blank? %> <h1> flash hash is blank </h1> <% end %>
If you see that the "flash hash is empty" in your browser, you know what that means.
EDIT : -
Something from the documents "Just remember: they will disappear by the time the next action is completed." Try this on your controller
flash.keep(:message) #keep the flash entry available for the next action
Source: https://habr.com/ru/post/1723603/More articles:How can I make this line from "textarea" for one line? - htmlCompiled OK, but NoClassDefFoundError on startup - javaVIM plugin VTreeExplorer (view in the IDE style for VIM) - vimHow portable Windows executables are portable across the entire machine architecture - windowsIs Ruby Ready? IO method with get, puts, etc. - ruby | fooobar.comMVVM questions with Josh Smith as an example - c #С#/Lambda: запрос параметра параметра объекта (noob) - c#Есть ли способ сделать Visual Studio 2010 больше похожим на VS 2008? - visual-studio-2010Calculate GDI + drawing bounding box - c #result.viewname is always string.empty - c #All Articles