Today i learned from raji akka, How to customise our “Rails Project’s Home page”.
Rails comes with built-in support for SQLite3, choose to use MySQL instead of the shipped Sqlite3 database. Open tour terminal and follow the following commands. Here “universal” is our project name.
rails new universal -d mysql
Go to “universal” Directory
Here, our config/database.yml will look a little different. If your development computer’s MySQL installation includes a root user with an empty password, this configuration should work for you. Otherwise, change the username and password in the development section as appropriate.
Foe Example, In app–>view, we are creating “world” and “moon” name files. Here “world” folder have “moon.html.erb” file
rails generate controller world moon
Lets check the default home page.
Open the link and look the welcome page.(Welcome aboard)
Now, we have to remove default “index.html” file. Go to public folder and remove the html file.
Now, we have to tell Rails where our actual home page is located. So, Next we have to go “config” folder and have to edit “routers.rb” file.
This file contains many sample routes on commented lines, and one of them actually shows you how to connect the root of your site to a specific controller and action. Find the line beginning with root :to uncomment it and change it like the following:
Now we are going to write a html program. Open the following file and erase the old program and we have to add our program.
My Sample html program.
<html> <body style="background-color:PowderBlue;"> <h1>Welcome to World And Moon </h1> <p style="font-family:verdana;color:red"> This page designed in simple html code </p> <p style="font-family:times;color:green"> Think Better! live Better!</p> <p style="font-size:30px">You can also customise your's "Rails Project Home page"</p> </body> </html>
Now, we again start the rails server and open the localhost, Then see the new welcome page.
That’s all !!!
If you have any doubt, feel free to ask me