journalduhacker/app/helpers/application_helper.rb
joshua stein 9f5e04bbba use _path for most things instead of _url
Instead of hard-coding the scheme and host everywhere, use _path
methods to show relative URLs.

Except that our previous setting of
Rails.application.routes.default_url_options in
config.after_initialize made this moot because Rails inserts that
host into all _path helpers for some reason.  So revert that
setting.

But then anything that wants an absolute URL doesn't know the
hostname and the root_url helper throws an exception.  So make a
Rails.application.root_url shortcut to pass the per-app settings in
Rails.application to root_url.

Now we can just use _path helpers most places but still use _url
ones where we need them, such as in RSS views and e-mail templates.
2015-01-02 17:02:55 -06:00

20 lines
443 B
Ruby

module ApplicationHelper
def errors_for(object, message=nil)
html = ""
unless object.errors.blank?
html << "<div class=\"flash-error\">\n"
object.errors.full_messages.each do |error|
html << error << "<br>"
end
html << "</div>\n"
end
raw(html)
end
def time_ago_in_words_label(*args)
label_tag(nil, time_ago_in_words(*args),
:title => args.first.strftime("%F %T %z"))
end
end