routes: replace hardcoded routes in models with route helpers.
Add a Routes module that gives models access to route helpers outside of views, and use it to replace various hardcoded routes.
This commit is contained in:
11
app/logical/routes.rb
Normal file
11
app/logical/routes.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# Allow Rails URL helpers to be used outside of views.
|
||||
# Example: Routes.posts_path(tags: "touhou") => /posts?tags=touhou
|
||||
|
||||
class Routes
|
||||
include Singleton
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
class << self
|
||||
delegate_missing_to :instance
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user