I have some custom helper classes under lib/ that need to access the
routes (link_to/url_for/etc):
But when I call <%= magic_link Product.first %> from the view it renders
the error
I have some custom helper classes under lib/ that need to access the
routes (link_to/url_for/etc):
But when I call <%= magic_link Product.first %> from the view it renders
the error
Gudleik R. wrote in post #966781:
I have some custom helper classes under lib/ that need to access the
routes (link_to/url_for/etc):
http://gist.github.com/520529But when I call <%= magic_link Product.first %>
NEVER DO THAT! Product.first does a database call. Therefore, it
should never be used in the view. The view should never, ever touch
the database under any circumstances. Instead, make the database call
in the controller and set an @instance variable.
from the view it renders
the error
What error?
You’ll probably need to include ActionController::UrlWriter in your
helper.
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs