app/helpers/title/title_helper.rb in title-0.0.3 vs app/helpers/title/title_helper.rb in title-0.0.4
- old
+ new
@@ -12,11 +12,11 @@
end
def to_s
I18n.t(
[:titles, controller_name, action_name].join('.'),
- context.merge(default: [application_title, guess_title])
+ context.merge(default: defaults)
)
end
private
@@ -28,11 +28,25 @@
def guess_title
Rails.application.class.to_s.split('::').first
end
+ def defaults
+ default_keys_in_lookup_path + [application_title, guess_title]
+ end
+
def controller_name
controller_path.gsub('/', '.')
+ end
+
+ def default_keys_in_lookup_path
+ defaults = []
+ lookup_path = controller_name.split('.')
+ while lookup_path.length > 0
+ defaults << ['titles', *lookup_path, 'default'].join('.').to_sym
+ lookup_path.pop
+ end
+ defaults.reverse
end
end
end
end