Assume that, you're in
class SomeService # 🦄 include the url_helpers include Rails.application.routes.url_helpers user_path end
app.user_path #=> "/user"
 pry(#<UserController>)> controller_path => "user"  pry(#<UserController>)> action_name => "index"
There are two ways.
File.expand_path(relative_path, __FILE__) # from the current source file File.expand_path(relative_path, __dir__) # from the current source file
Classic DEV Post from May 4