Skip to content

Instantly share code, notes, and snippets.

@Yama-to
Last active August 29, 2015 14:26
Show Gist options
  • Save Yama-to/15ce02e815cb8304817e to your computer and use it in GitHub Desktop.
Save Yama-to/15ce02e815cb8304817e to your computer and use it in GitHub Desktop.
redirect_to使った時にBootstrap対応のフラッシュメッセージを表示させる ref: http://qiita.com/Yama-to/items/4d19a714d8bf5bfbabdd
%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"
class ApplicationController < ActionController::Base
add_flash_types :success, :info, :warning, :danger
end
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