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)
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/concerns/effective/flash_messages.rb', line 21 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 ||= if resource.respond_to?(:destroyed?) && resource.destroyed? resource_human_name else resource.to_s.presence || resource_human_name end ["Unable to #{action}", (" #{name}" if name), (": #{messages}" if )].compact.join.html_safe end |