Module: Mails::ApplicationHelper

Defined in:
app/helpers/mails/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#notice_messageObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/mails/application_helper.rb', line 14

def notice_message
  flash_messages = []

  flash.each do |type, message|
    type = :danger
    type = :success if type.to_sym == :notice
    close_button = raw %(<button type="button" class="close" data-dismiss="alert">×</button>)
    text = (:div, close_button + message, class: "alert alert-dismissible alert-#{type}")
    flash_messages << text if message
  end

  flash_messages.join("\n").html_safe
end

#render_errors(target) ⇒ Object



3
4
5
6
7
# File 'app/helpers/mails/application_helper.rb', line 3

def render_errors(target)
  if target.errors.present?
    render partial: '/homeland/shared/error_messages', locals: { target: target }
  end
end

#timeago(time, options = {}) ⇒ Object



9
10
11
12
# File 'app/helpers/mails/application_helper.rb', line 9

def timeago(time, options = {})
  options[:class] ||= "timeago"
  (:abbr, time.to_s, options.merge(:title => time.getutc.iso8601)) if time
end