Last active
August 29, 2015 14:26
-
-
Save Yama-to/15ce02e815cb8304817e to your computer and use it in GitHub Desktop.
redirect_to使った時にBootstrap対応のフラッシュメッセージを表示させる ref: http://qiita.com/Yama-to/items/4d19a714d8bf5bfbabdd
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
%body | |
= render "layouts/header" | |
- flash.each do |key, value| | |
- key = "info" if key == "notice" | |
- key = "danger" if key == "alert" | |
= content_tag :div, value, class: "alert alert-#{key}" | |
= yield | |
= render "layouts/footer" |
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
class ApplicationController < ActionController::Base | |
add_flash_types :success, :info, :warning, :danger | |
end |
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
def create | |
review = current_user.reviews.new(review_params) | |
if review.save | |
redirect_to books_url, success: "Successfully created your prototype." | |
else | |
redirect_to root_url, warning: "Unfortunately failed to create." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment