Skip to content

Instantly share code, notes, and snippets.

@nashirox
Last active February 8, 2018 13:43
Show Gist options
  • Save nashirox/dd736f561f40aef84a49b3ca5efcf2b9 to your computer and use it in GitHub Desktop.
Save nashirox/dd736f561f40aef84a49b3ca5efcf2b9 to your computer and use it in GitHub Desktop.
%body
- flash.each do |key, value|
- key = "info" if key == "notice"
- key = "danger" if key == "alert"
= content_tag :div, value, class: "alert alert-#{key}"
class ApplicationController < ActionController::Base
# フラッシュメッセージのキーを追加
add_flash_types :success, :info, :warning, :danger
end
class SamplesController < ApplicationController
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
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment