In a Rails 3.2 app I need to access url_helpers in a lib file. I\'m using
Rails.application.routes.url_helpers.model_url(model)
<
Use this string in any module controller to get application URL-helpers works in any view or controller.
include Rails.application.routes.url_helpers
Please note, some internal module url-helpers should be namespaced.
Example: root application
routes.rb
Rails.application.routes.draw do
get 'action' => "contr#action", :as => 'welcome'
mount Eb::Core::Engine => "/" , :as => 'eb'
end
Url helpers in module Eb:
users_path
Add include Rails.application.routes.url_helpers in controller contr
So after that helper should be
eb.users_path
So inside Eb module you can use welcome_path same as in root application!