Class: Notification

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/generators/acts_as_notificable/templates/notification.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_notification(template_name, locals = {}) ⇒ Object



15
16
17
# File 'lib/generators/acts_as_notificable/templates/notification.rb', line 15

def self.create_notification(template_name, locals = {})
  Notification.create(template_name: template_name, locals: locals)
end

Instance Method Details

#render(options = {}) ⇒ Object



8
9
10
11
12
13
# File 'lib/generators/acts_as_notificable/templates/notification.rb', line 8

def render(options = {})
  locals.merge!(notification: self)
  render_options = { file: "notifications/#{template_name}", locals: locals }
  render_options[:layout] = "layouts/" + options[:layout] if options.has_key?(:layout)
  view.render(render_options)
end