Module: FrontendNotifierControllerExtension

Defined in:
lib/frontend_notifier/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#notify_frontend(message, error_type = "error") ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/frontend_notifier/application_controller.rb', line 3

def notify_frontend(message, error_type="error")
  unless message.kind_of? String || message.nil?
    if message.errors.empty?  
      message = "Success"
      error_type = "success"
    else
      message = join_model_errors(message) 
    end
  end
  render :json => { :type => error_type, :message => message  }
end