Welcome back again to the know-how series on Ruby On Rails .This post will help you in setting up the development environment so that in fututre we use this setup to build our web applications.
We will also see about the integration of MySQL and RoR.
To start with I request you all to install MySQL server .To do that please follow the instructions given in the below link.
Now create two users in Mysql for 2 different environments. There are 3 major enviroments in RoR. Development, Testing, Production. As of now I am concentrating on Development and Testing Environment.
So create users and grant all permissions or privileges .Now how to do that please follow the link below .
Make sure that you have two different database schema .In my case I have a database schema linuxcandy and user linuxuser, and the other database schema is linuxtestcandy and the user created is testuser.
Go to src folder and open the file database.yml file and do the following changes .
If you carefully observe the pic there is an field called adapter and I have given mysql. Imagine If I would have not given this then how the heck will RoR communicate with MySQL . It has to be redirected right (poor guy,..lets help him). So we need install gems (for time being think it as a library having some api’s ).
Here is the list of gems that you need to install . To know what gems are installed locally in your machine , you can type ‘gem list’ in the console (no quotes please ).
The link to get the gems are http://rubygems.org/.
The game is not yet finished . You also need to install some libraries from synaptic manager. Go to synaptic manager and install libmysqlclient16.
Setting up the environment is the big thing as by next week you actually write programs that will update the database and show the contents in html and stuff like that. So I request you guys to setup the development environment and If you face any issues try googling it or else just post the error in the comment section and I will try to resolve it.
Till now you have seen how we used to get the html display by entering the url as localhost:3000/controller_name/method_name .Right ?. Look into the previous articles incase you hav forgot .
But that pathetic right.Nobody does that . All you type is say www.ABCD.com and automatically the server should redirect to the welcome page . So what I meant is how can we tell or set some html as our welcome page and when the user enters the base url it should automatically redirect to the specified page..! Well the solution is to modify few lines in a file called routes.rb which is under config folder.
Since the name of our first program was our_first_program , we had an action called index which would load , but the thing was we used to write http://localhost:3000/our_first_program right…remember (look into the previous articles ) .
But by modifying the above said file that is routes.rb ( under config folder) we can directly land on t o this page by just typing localhost:3000
[Make sure you delete the index.html file from the public folder.]
Let me know If you face any issues.