I have some static pages I am trying to make like team, aboutUs, terms of service, etc.
I am trying to make one controller to handle the static pages, but I am missing some know-how.
Here is what I did:
In routes.rb, before the end I added this:
match "/:action" => "pages"
Then I made a controller named pages_controller.rb
Currently it is empty. What I need it to do is recognize the requests like /pages/team or pages/about_us and redirect to the right static page. How can I do that?
Thank you!
This is how I do it:
Then based on
params[:page]i render different static views.This works good for me, for sites with a smaller number of static pages.
Of course you can explicitly name your routes:
and then declare an empty method for each route in your Pages controller:
but I prefer the first way.