Help creating a route and controller for static pages

I have static pages that I am trying to do as a team, aboutUs, terms of service, etc.

I am trying to get one controller to process static pages, but I lack some know-how.

Here is what I did:

In routes.rb, I added the following to the end:

match "/:action" => "pages"

Then I created a controller named pages_controller.rb

It is currently empty. What I need is to recognize requests such as / pages / team or pages / about_us, and redirect to the desired static page. How can i do this?

Thank!

+5
source share
2 answers

Here is how I do it:

match '/pages/:page' => "pages#page"

params[:page] . , .

, :

match '/about-us' => "pages#about_us"

:

def about_us
end

.

+5

- - :

map.connect '* path',: controller = > ' ',: action = > 'show'

* path , , .

: action = > 'show' (, ) , .

subdirs...

app/views/ /some -new-subdir/foo.html.erb, , :

http://example.com/some-new-subdir/foo

0

All Articles