I would like to use a custom method to build my routes.
Currently, I have something like this in my routes.rb file :
Foobar::Application.routes.draw do
def my_custom_method
# lot
# of
# code
end
pages = my_custom_method
pages.each do |key, slug|
get slug => 'pages#view', as: key, defaults: { slug: slug }
end
end
But I’m sure it’s not its place.
So where should I store this custom method ?
Which is the “good way” ?
A working solution is to create the file
config/initializers/routes.rbcontaining: