Module: Releaf::ActionController::Notifications

Extended by:
ActiveSupport::Concern
Included in:
Releaf::ActionController
Defined in:
app/lib/releaf/action_controller/notifications.rb

Instance Method Summary collapse

Instance Method Details

#notice_scope_nameObject

Returns notice scope name


25
26
27
# File 'app/lib/releaf/action_controller/notifications.rb', line 25

def notice_scope_name
  'notices.' + controller_scope_name
end

#render_notification(status, success_message_key: "#{params[:action]} succeeded", failure_message_key: "#{params[:action]} failed", now: false) ⇒ Object

Tries to return resource class.

If it fails to return proper resource class for your controller, or your controllers name has no relation to resource class name, then simply override this method to return class that you want.


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/lib/releaf/action_controller/notifications.rb', line 10

def render_notification(status, success_message_key: "#{params[:action]} succeeded", failure_message_key: "#{params[:action]} failed", now: false)
  if now == true
    flash_target = flash.now
  else
    flash_target = flash
  end

  if status
    flash_target["success"] = { "id" => "resource_status", "message" => I18n.t(success_message_key, scope: notice_scope_name) }
  else
    flash_target["error"] = { "id" => "resource_status", "message" => I18n.t(failure_message_key, scope: notice_scope_name) }
  end
end