I need pass in charge attributes in model contract_url(contract) I have following code in model CheckoutService:
delegate :url_helpers, to: 'Rails.application.routes'
def contract_url(cont)
url_helpers.contract_url(cont)
end
In charge_attributes i need set url for attribute secureUrl, for example:
charge_attributes
{
secureReturnUrl: contract_url(contract)
}
I get an error:
ActionController::UrlGenerationError: No route matches {:action=>"show", :controller=>"contracts", :locale=>#<Contract id: 13, ..} missing required keys: [:id]
rake routes:
contract GET (/:locale)/contracts/:id(.:format) contracts#show {:locale=>/en|fr/} PATCH (/:locale)/contracts/:id(.:format)
If i call this url helper in controller or view work correct. How pass current locale in url in model? Thank you.