Rails 4 Static Pages – How To

Creating Rails 4 Static Pages is really straightforward.

We all at some point needed to create a static page like an About or Contact us page. Rails 4 Static Pages are easy to create and the procedure is slightly different than Rails 3.

In Rails 3 you had to use the match method like:

match ':action' => 'static#:action'

However in Rails 4 the Static Pages can be created by using:

get ':action' => 'static#:action'

By doing that you have setup your Static’s page route. However you also need to create your static_controller.rb and input your “action” there. After that you need to create the app/views/static folder and make an action.html.erb file.

Your Rails 4 Static Page is now ready and visible when you browse to http://localhost:3000/action

Discussions — No responses yet