Creating Ruby On Rails Applications

How to create a sample Ruby on Rails application on Webmasters.com

NOTE: You will need to install Ruby on Rails (RoR) on your own PC in order to generate the rails framework.

This sample application is named "testapp". Our sample table is "people" and our sample model/controller is named "Person". (This works automatically because rails knows that the plural of "person" is "people").

Via your control panel:

1. Create the development database you will use for the rails application. Note the database name, username and password.

2. Create a sample table in MySQL:

create table people (id integer not null auto_increment primary key, name varchar(48) not null);

On your own PC with RoR installed:

3. Create a rails application framework.

C:\> rails testapp

4. Add the database information from step 1 to testapp/config/database.yml:

development:
adapter: mysql
database: DBNAME
username: USERNAME
password: PASSWORD
host: localhost

5. Generate the necessary ruby code.

C:\> ruby script/generate model Person
C:\> ruby script/generate controller Person

6. Add the line "scaffold :person" inside the class declaration in the
file testapp/app/controllers/person_controller.rb

7. Verify that the first line in testapp/public/dispatch.cgi is:

#!/usr/bin/ruby

Also verify that dispatch.cgi has executable permissions set (mode 755).

8. Upload your application to your account. Browse to your application:

http://www.yourdomain.com/testapp/public/person

You should see a basic scaffolding page allowing you to add/change/delete "person" entries.

(Optional) Create an index.html to redirect top-level requests containing:

<meta http-equiv="Refresh" content="1; URL=/testapp/public/">

(Optional) When your application is ready for production, edit public/.htaccess

Change: RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
To: RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
 

About Us | Domain Names | Web Hosting | Servers | Web Design | Make Money | Site Map | Home
© Copyright WEBMASTERS.COM. All Rights Reserved.