Skip to content

Instantly share code, notes, and snippets.

@raj-adroit
Last active October 13, 2015 23:48
Show Gist options
  • Select an option

  • Save raj-adroit/4275317 to your computer and use it in GitHub Desktop.

Select an option

Save raj-adroit/4275317 to your computer and use it in GitHub Desktop.
display flash notice message in rails
#Example action in the controller for flash notice
def create
@subject = Subject.new(params[:subject])
if @subject.save
flash[:notice] = "Subject created" # set the flash notice here before redirecting
redirect_to(:action => 'list') # Redirect the page to list view
end
end
# place this code in the list view or layout of that view
<%if !flash[:notice].blank? %>
<div class="notice">
<%= flash[:notice]%>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment