How to use url helpers in lib modules, and set host for multiple environments

前端 未结 4 637
情深已故
情深已故 2020-12-25 14:43

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)
<
4条回答
  •  感动是毒
    2020-12-25 15:31

    Not sure if this works in Rails 3.2, but in later versions setting default url options for the routes can be done directly on the routes instance.

    So for example, to set the same options as for ActionMailer:

    Rails.application.routes.default_url_options = ActionMailer::Base.default_url_options
    

提交回复
热议问题