mercredi 3 août 2016

Rails 3: url helper always raise errors in models or console, but work fine in controllers/views

A simple Rails.application.routes.url_helpers.root_path (or any other route) will throw ActionController::RoutingError: No route matches ... if called from a model, rails console or a view rendered with render_to_string, but the same root will work fine in a controller or view rendered the usual way.

Calling a model method using url_helpers from a view or a controller will also raise the same exception, so I don't think it's due to the lack of request.

The project is using rails 3.0, and what I tried works fine on other rails 3.0 projects.
Would you have any idea where to look to solve this?

Aucun commentaire:

Enregistrer un commentaire