Method: Effective::FlashMessages#flash_danger
- Defined in:
- app/controllers/concerns/effective/flash_messages.rb
#flash_danger(resource, action = nil, e: nil, name: nil) ⇒ Object
flash.now = flash_danger(@post)
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/concerns/effective/flash_messages.rb', line 13 def flash_danger(resource, action = nil, e: nil, name: nil) raise 'expected an ActiveRecord resource' unless resource.respond_to?(:errors) && (name || resource.class.respond_to?(:model_name)) action ||= resource.respond_to?(:new_record?) ? (resource.new_record? ? :create : :update) : :save action = action.to_s.gsub('_', ' ') = flash_errors(resource, e: e) name ||= resource.to_s.presence ["Unable to #{action}", (" #{name}" if name), (": #{}." if )].compact.join.html_safe end |