Module: NamedRoutesOptions
- Defined in:
- lib/rails-named-routes-options.rb
Overview
Usage ===
class InvitationsMailer < ActionMailer::Base
[:only_path] = false
end
or just: ActionMailer::Base.default_named_routes_options = false
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#default_named_routes_options ⇒ Object
23 24 25 |
# File 'lib/rails-named-routes-options.rb', line 23 def @default_named_routes_options ||= Hash.new end |
Class Method Details
.extended(mailer) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rails-named-routes-options.rb', line 27 def self.extended(mailer) super(mailer) mailer.class_eval do self.routes_names.each do |route| helper_method "#{route}_path", "#{route}_url" define_method("#{route}_path") do |*args| = args.last.is_a?(Hash) ? args.pop : Hash.new args.push(.reverse_merge!(:only_path => false)) super(*args) end alias_method "#{route}_url", "#{route}_path" end end end |
Instance Method Details
#routes_names ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/rails-named-routes-options.rb', line 12 def routes_names methods = self.instance_methods methods.grep(/_path$/).inject(Array.new) do |result, method| name = method.match(/^(.+)_path$/)[1] result.push(name) if methods.include?("#{name}_url") result end end |