How to change the index page for rails?

I know that in order to change the index page for rails I need to do three things: remove index.html, do something with route.rb, and possibly take the action that the route points to. These are the details that I'm a little fuzzy :-)

+4
source share
4 answers

Ok, I figured it out. Basically you

  • Delete public.html
  • Add 'map.root: controller => "foo"' to routes.rb
  • and then of course create a foo controller with an action index.
+13
source

Follow the Frew steps and, as step 4, put the small html file in the index view file in the / views / foo folder to check everything.

Example:

<h1>My New Index Page</h1> <p>Some text here.</p> 
+5
source

Do not forget to restart the server.

You can also run rake routes to show all known routes and make sure everything looks normal.

+3
source

Please note that this has changed in RoR version 4.0+ - follow the simple steps in the getting started guide !

In a few minutes it will become clear how this works.

I just thought it was worth updating this threat, because those who use a newer version may get confused and upset :)

+1
source

Source: https://habr.com/ru/post/1277516/


All Articles