How to create your first ROR app with mysql database support on windows?

When you are creating your first app on ruby on rails it default supports “sqlite” database. You can see it while open the “Gemfile” of  your project using a text editer like “Sublime Text”. When your app’s data are growing  bigger n bigger the “sqlite” is not suitable to store that data. So there are some alternative database systems for that like “mysql”,”postgresql” or “oracle”. My preferred choice is mysql. So .in this post I’ll show you how to create you first ROR app that includes mysql database support.

First you have to install gemfile for mysql . This can be install issuing the following command in the terminal window.

 gem install mysql2

After that you can see the following progress on the terminal window

installing_mysql2_rubygem_on-windows

Then issue the following command to create new rails app that includes mysql support

 rails new testr -d mysql

After few minutes that will create your new rails app.

Now move to the development directory issuing the following command on terminal window.

 E:\>cd testr

Then issue the following command in  the terminal to run the app

 E:\testr> rails server

rails-_boot_up

Then open your web browser and  type the following url in the address bar

 http://localhost:3000

database_error

Oops.. ! . There is an error occurred 😦 . What can we do to resolve that error ?.

Ok, lets examine the database.yml in your app directory (in my example testr) using “Sublime Text” editor.

database_yml_sublime

It shows us that there is a predefined database “testr_development” and we haven’t a database in our mysql server.

So to get rid of this we open the mysql command line interface and must issue the following command in it

 mysql> create schema testr_development;

testr_database_schema

After that refresh the browser window and also see the terminal window. You can see that following  result shows mysql is correctly configured with you project.

terminal_suucess_rails.png

suucess_ror_mysql

Yay! Now you know how to make ROR app with the support of mysql database.

Thats all .

Have happy coding and have a nice day 🙂 !

How to create your first ROR app with mysql database support on windows?

Finally upgraded to ROR 5 !

I’ve experimenting web developing on Ruby on Rails as a hobby. Last few days I’ve work with ruby 1.9.3 and ROR 3.2.x and felt that I must move to ruby version 2.x.x and  ROR 5 because ROR community fastly moved to new ROR version and old version is being deprecated. So here I’ve show you what is on it. Before that below screenshot shows that how the old ROR 4 start page looks like . Because I loved that very much :-).

RUBY_ON_MY_MACHINE - Copy

Let’s rock on!

Here firstly I’ve fully removed ruby 1.8.7 and ROR 4 from my machine. After that I’ve installed ruby 2.2.4 and ROR 5.0.0.1

After that in the terminal I’ve issued the following command

>rails new first_app

So it creates a new rails app

Untitled

Oh looo..ong Screenshot 😀

After that move to that newly created rails app folder and issue the following command in the windows or linux terminal.

first_app>rails server

ROR2

After that type the following url in your web browser

http://localhost:3000/

Now you can see the browser screen as below.

ROR1

Yay 😀 it rocks !

The main difference is the welcome page is been changed and it’s clean and simple .Also the web server moved to “WEBRICK” to “PUMA”.

Thats it !

 

Finally upgraded to ROR 5 !