Getting RuntimeError: "To use #url_for, you must explicitly enable routing helpers" when I already turned them on

Inside the controller, I tried to run this code when users who were already logged in stumbled upon a registration page

def index
  if current_user
    redirect_to homebase_url #should provide url to home for logged in users
  end
end

I did what the rails error message said, and added: include Rails.application.routes.url_helpersto the containing controller class. However, get this error. You definitely do not want to embed URLs in legacy targets. Thanks

+4
source share
2 answers

include Rails.application.routes.url_helpers, , . . / ( ) MVC .

+2

homebase_path homebase_url

, http://stackoverflow.com/questions/41903124/getting-runtimeerror-in-order-to-use-url-for-you-must-include-routing-helper/42048113#42048113

console.log(window.location.pathname) // => "/questions/41903124/getting-r..."
console.log(window.location.host) // => "stackoverflow.com"

- ().

URL ( homebase_url) host, . , , , .

+1

Source: https://habr.com/ru/post/1668047/


All Articles