Last active
October 13, 2015 23:48
-
-
Save raj-adroit/4275317 to your computer and use it in GitHub Desktop.
display flash notice message in rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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