Sometimes you may want some code in your model to have accesss to Rails routing helpers. You can access these methods anywhere in the application.


Rails.application.routes.url_helpers.posts_path

Rails.application.routes.url_helpers.post_path(post)

Its simple actually.


Related External Links: