WashesWhiter.com
Flash+PHP+MySQL databases | scripts | tutorials | contact






RAILS
DEVELOPER
EMAIL
MARKETING
SUBMISSION
PAGE DESIGN
HTML TABLES
CSS TEXT
FONTS
IMAGES
FLASH
SECURITY
tutorials


Instant Rails: GET STARTED WITH RAILS THE EASY WAY


You can get Ruby web space hosting here:


1. INSTALL Instant Rails

Download Instant Rails from HERE
Unzip and put in c:\rails

2. GET Instant Rails RUNNING

Click on Instant Rails application file.
The application should look like this:



Click on the I icon and Rails Applications | Manage Rails Applications.
Click on



and you should get a window something like this:



At the prompt, run the command:

rails contactslist

This will create a contactslist subdirectory containing a complete directory tree of folders and files for an empty Rails application.



Close the Rails Applications box and open it again.
Click on contactslist checkbox.
Now click on Start with WEBrick.
Open a browser and go to http://127.0.0.1:3000/
You should see a page which says "Welcome aboard"
Leave the command window open and the WEBrick running.

3. DIRECTORY STRUCTURE

A Rails Application's Directory Structure

Rails tries very hard to minimize the number of decisions you have to make and to eliminate unnecessary work. When you used the rails helper script to create your empty application, it created the entire directory structure for the application. Rails knows where to find things it needs within this structure, so you don't have to tell it. Remember, no configuration files!

Most of our development work will be creating and editing files in the c:\rails\rails_apps\contactslist\app subdirectories. Here's a quick rundown of how to use them.

* The controllers subdirectory is where Rails looks to find controller classes. A controller handles a web request from the user.
* The views subdirectory holds the display templates to fill in with data from our application, convert to HTML, and return to the user's browser.
* The models subdirectory holds the classes that model and wrap the data stored in our application's database. In most frameworks, this part of the application can grow pretty messy, tedious, verbose, and error-prone. Rails makes it dead simple!
* The helpers subdirectory holds any helper classes used to assist the model, view, and controller classes. This helps to keep the the model, view, and controller code small, focused, and uncluttered.

Controllers and URLs

In a moment, we will create our contactslist database and begin developing our application. First, it's important to understand how controllers work in Rails and how URLs map into (and execute) controller methods.
Controller classes handle web requests from the user. The URL of the request maps to a controller class and a method within the class.

4. CONTROLLER CLASS

We will use another Rails helper script to create a new controller class for us.
In the command window, where it says c:\rails\rails_apps> run the command:

cd contactslist

to produce

c:\rails\rails_apps\contactslist>

Now type in:

ruby script\generate controller MyTest

and press return.
This will create a file named my_test_controller.rb containing a skeleton definition for the class MyTestController.

In C:\rails\rails_apps\contactslist\app\controllers, open my_test_controller.rb and type in

def index
render_text "Hello World"
end

so it looks like this:

class MyTestController < ApplicationController
def index
render_text "Hello World"
end
end

Now go to http://127.0.0.1:3000/My_Test/ in the browser and you should see Hello World.

5. CREATE THE CONTACTSLIST DATABASE

Now to create the contactslist database and tell Rails how to find it. (This is the only configuration that you will find in Rails.)

Look at c:\rails\rails_apps\contactslist\config\database.yml and decide if you want the database called contactslist_development, contactslist_production or contactslist_test.

If you are developing on your machine, then leave
username: root
password:
as they are. You will have to put in the values if the database is online.

Ignore
socket: /path/to/your/mysql.sock
Just leave it.

6. SET UP DATABASE

Close the Rails Applications box.
In the Instant Rails application, go to Configure | Database (via PHPMyAdmin) and open PHPMyAdmin



Create a new database called contactslist_(whatever). I use contactslist_development.

In PHPMyAdmin, create the table called addresses and add the fields you want.
In the console window cmd.exe, run the command:

ruby script\generate scaffold Address

In c:\rails\rails_apps\contactslist\app\controllers you should now have a file called addresses_controller.rb
Go to http://127.0.0.1:3000/addresses/new and you should see the data entry page. Try entering a couple of addresses.

You have now set up the database.

7.TO BE CONTINUED

This tutorial will be continued when I have time.

8.REFERENCE
9. RUBY HOSTING

You can get Ruby web space hosting here:


10. FOR THE SEARCH ENGINES.

ruby rails InstantRails getting started set up tutorial tute instructions install manual help assistance beginner