class Humpyard::NewsItem
Public Instance Methods
human_url(options={})
click to toggle source
Return the human readable URL for the page.
Posible options values are
:locale
-
A locale given in the Humpyard::Config.locales. If no
:locale
is given the option will be ::I18n.locale by default
# File app/models/humpyard/news_item.rb 21 def human_url(options={}) 22 options[:locale] ||= ::I18n.locale 23 options[:format] ||= :html 24 25 unless Humpyard::config.locales.include? options[:locale].to_sym 26 options[:locale] = Humpyard::config.locales.first 27 end 28 29 if options[:path_format] 30 format = "/" 31 else 32 format = ".#{options[:format].to_s}" 33 end 34 35 page_options = options 36 page_options[:path_format] = true 37 38 "#{news_page.page.human_url(page_options)}#{created_at.strftime '%Y/%m/%d'}/#{query_title_for_url(options[:locale])}#{format}" 39 end