Rails: using url helpers inside custom class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module UrlHelpers | |
extend ActiveSupport::Concern | |
def default_url_options | |
Rails.configuration.action_mailer.default_url_options | |
end | |
included do | |
include Rails.application.routes.url_helpers | |
end | |
end | |
class MyClass | |
include UrlHelpers | |
end | |
MyClass.new.instance_eval { root_url } | |
=> "http://localhost:3000/" | |
MyClass.new.instance_eval { registration_url } | |
=> "http://localhost:3000/registration" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment