In a model callback I make an API call and need to give the API some URLs. Those URLs would be easily generated by a routing helper.
The solution given in this answer does not work anymore in Rails 3.
Any solution? Thanks :)
Got an answer from the rails IRC: just add
include Rails.application.routes.url_helpers
to your model
In Rails 3 you can use:
Rails.application.routes.url_helpers
eg
Rails.application.routes.url_helpers.posts_path
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.