Reputation: 6057
I have a class method in application_controller.rb:
def self.method1
path = some_path
end
Now it seems I can't access some_path since usually I'll need to use route in a controller (instance method).
What is the best way to access routes here?
Thanks
Upvotes: 4
Views: 2424
Reputation: 3436
you may simply get the path using the following line of code
def foo
path = request.path
end
Upvotes: 0
Reputation: 8836
This should work from anywhere in your application
path = Rails.application.routes.url_helpers.some_path
Upvotes: 9