1) Set up the MySQL tools on your computer from the below link.
http://dev.mysql.com/downloads/gui-tools/5.0.html
After download progress is completed, you will need to open your Windows Vista Firewall to permit MySQL connections to the MySQL server port (3306). To do so, open Control Panel again, and select the Allow a program through Windows Firewall option of the Security group.

Finally, you can start installing MySQL. Double-click the Windows Essentials MySQL setup program to get started:

Select the default (“Typical”) settings and location and let the program install itself.

After, installation and configuration processes, you still need the Ruby on Rails gems. Install them with the command "C:\> gem install rails capistrano mongrel mongrel_cluster".
The MySQL adapter gem needs to be installed next. "C:\> gem install mysql"
Once the command completes, you should be able to use ruby on MySql database.
2) Rails will setup a new application directory for each of your Web application projects. Get InstantRails (Windows) or Locomotive (MacOS) running on your machine. Both packages install Ruby, Rails, a Web server or one called ‘Mongrel’ or another small Ruby Web server called ‘WEBrick’, and MySQL “inside a bubble” as I call it so that others parts of your system are not modified (Similarly ZOPE does with installing its own Web server and Python versions).
As it is introduced on workshop 2, I prefered to get InstantRails because of my computer's operating system. We can see its file system and content on below window.

3) Once Rails is running you at http://localhost:3000, you need to configure database access. Connection to the database is specified in the config/database.yml file.
On this project, I am going to use sqlite3 database system. So, I need to specify, it's configuration requrements.
4) Generate the Passenger model by creating the MySQL database.
Now, we need to create required table for our application. Command by "ruby script/generate scaffold origin name:string contact_no:integer suburb:string street:string street_no:integer building:integer"After this process, you have to command "rake db:migrate" to create MVC based files.


After these two commands, table is cretated on sqlite3 database and other required files for model, view and controller directories are created as well. So, we need to restart web server with mongrel.
Then, open a web browser and type "http://localhost:3000/origins"




Now, we have two separate tables and their belongings with MVC files. After that point, we need to create an association between destination which is shown on workshop 2 and origin. So, associations allow abjects to interact.
Associations are methods that map the primary keys of one table to the foreign keys of another; the relational mapping part of “object-relational mapping”.
Open app/models/destination.rb and modify its contents with the following window:
Key word is on this screen is belongs_to :origin. The belongs_to method provides association with another table that we wish to associate. And this table (destinations) has a foreign key column called origin_id that will reference the id column in the origins table.
After all association processes are completed, final screens will be like below.
5) Further work on understanding MySQL under Rails by David Mertz:
a. See “Fast-track your Web apps with Ruby on Rails” at http://www-128.ibm.com/developerworks/linux/library/l-rubyrails/
David Mertz, on this article, gives brief explanation about Ruby on Rails and its fundamental structure on MVC. In other words, it mentions that benefits of Ruby on Rails to the developers and how it uses MVC design pattern. These two main topicis were introduced in previous workshops. Moreover, on this article emphasize that code generation processes and creating an association between two different tables for a same application. Code genaration processes include generating the scaffold model and controller, and customize the view for user expectations. Besides that, all of them is working on MySql database, so he mentions how does ruby on rails work on MySql databese. Consequently, this article is quite useful to have strong knowledge on Ruby on Rails and MySql for beginners.
b. The “Rolling with Ruby on Rails” series and “Cookbook recipes by Curt Hibbs and others beginning at http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html
Rolling with Ruby on Rails article is a kind of user manual for beginners, because it mentions from installations processes to your first application's coding requirements, step by step. These are;
1. Ruby installation
2. MySql & MySql Front installation
3. Cookbook web application basic file creation.
4. Table and fields creation on MySql database.
5. Creating an association between a recipe and category tables
6. Summary
On this article, although, versions of Ruby and MySql are not latest ones, it is quite useful for beginners to understand what they need to start to learn ruby.








No comments:
Post a Comment