Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing Rails RESTful routes in the model

To clean up my code I would like access to the RESTful helpers in my Rails model. Something like:

users_path

etc.

Thanks.

like image 999
Jez Caudle Avatar asked Aug 10 '10 08:08

Jez Caudle


1 Answers

Just to re-open this: For all rails 3+ users including UrlWriter won't work as it's deprecated. What does work though, is this:

include Rails.application.routes.url_helpers

Hope that helps anyone who stumbled onto this like I did.

like image 135
te_chris Avatar answered Nov 20 '22 02:11

te_chris