using url_for in a lib folder module

后端 未结 2 1419
你的背包
你的背包 2021-02-13 02:58

I have a model with a field called \"type\" and a field called \"value\". The type field will determine how the \"value\" is parsed before rendering. I want this to be easily ex

2条回答
  •  鱼传尺愫
    2021-02-13 03:17

    An alternative to url_for you can use Rails.application.routes.url_helpers just add in route :as like the following example:

    get "sessions/destroy/:param_id", as: :logout 
    

    so you can use it as following:

    Rails.application.routes.url_helpers.logout_path(:param_id => your_value)
    

    This will do the same as url_for

    Hopefully, this would help

提交回复
热议问题