Ruby on Rails Meets Eclipse
Pages: 1, 2, 3, 4, 5
Creating a Rails Application
Next, we create a Rails project with File>New>Project. In the New gallery, select the Rails Project wizard and click on Next.

Figure 16. Creating a Rails project
Specify a project name, catalog, in the New Rails Project frame and select the options "Generate Rails Application skeleton" and "Create a WEBrick Server." Click on Finish. A Rails application gets created, as shown in the Rails Navigator view.

Figure 17. Rails application
We need to modify the database.yml file for the MySQL database:
development:
adapter: mysql
database: test
username: root
password:
host: localhost

Figure 18. Modifying database.yml
Create a database table, catalogs, in the MySQL database using SQL script:
CREATE TABLE catalogs(Journal VARCHAR(255),
Publisher VARCHAR(255),Edition VARCHAR(255),
Title Varchar(255), Author Varchar(255));
INSERT INTO catalogs VALUES('developerWorks',
'IBM', 'September 2006', 'A PHP V5 migration guide', 'Jack D. Herrington');
INSERT INTO catalogs VALUES('developerWorks',
'IBM', 'September 2006', 'Make Ruby on Rails easy with RadRails and Eclipse
', 'Pat Eyler');
Creating a CRUD Application
Next, we create the scaffolding for the database table catalogs. ActiveRecord uses pluralization; the database table name is the plural of the model class name with the first letter of the table name in lowercase. The scaffolding consists of model and controller scripts and RHTML view templates. Create the scaffolding with the scaffold generator. Select the Generators view and select the scaffold generator. Specify a model name, catalog, and click the Go button. A controller name is optional in the scaffold generator and defaults to the plural of the model name.

Figure 19. Creating scaffolding for the "catalogs" table
The scaffolding for the catalogs table gets created. The scaffolding consists of the model class, Catalog, which extends the ActiveRecord::Base class, and a controller class, CatalogsController, which extends the ApplicationController class, which in turn further extends the ActionController::Base class. The model script is generated in the app/models directory, and the controller script is generated in the app/controllers directory. The view templates, _form.rhtml, show.rhtml, list.rhtml, edit.rhtml, and new.rhtml get created in the app/views/catalogs directory. Next, we start the WEBrick server configuration for the Rails application, catalog, as shown in Figure 20.

Figure 20. Starting WEBrick server
The WEBrick server gets started. Display the WEBrick console with the URL http://localhost:3000. Display the list of the catalog entries with the controller action list. Invoke the list action with the URL http://localhost:3000/catalogs/list.

Figure 21. Listing catalogs
As you can see, a Ruby on Rails application may be created in a command-line tool, but it can also be created in Eclipse using one of the Ruby on Rails plugins for Eclipse.
Deepak Vohra is a NuBean consultant and a web developer.
Return to Ruby.
Showing messages 1 through 10 of 10.
-
Error: premature end of regular expression: /\A�/
2008-07-23 01:06:49 adriane [View]
-
Where are the images?
2007-10-10 04:49:17 cschlaefcke [View]
I hope it´s not my browser configuration, but I cannot display any of the screenshots. Maybe the links are corrupt?
Thanks & Regards,
Chris -
Where are the images?
2007-10-10 04:50:27 cschlaefcke [View]
Forget about it :-)
It just took pretty long to get them loaded...
Sorry!
Chris
-
Nice job Deepak!
2007-08-16 09:00:54 datakix [View]
I've been looking to use Eclipse and Rails and this is just the tutorial I needed to get started. I tried using Aptana and there 'how-to' documentation is lacking.
This is so much more efficient than using Notepad++ and the command window!
Thanks,
Datakix
-
In the Variable Input frame, specify catalog as the model name
2007-05-03 13:02:35 pksiv [View]
I don't understand what this means. -
In the Variable Input frame, specify catalog as the model name
2007-05-03 13:32:57 Deepak Vohra | [View]
Select Run>External Tools>Create Scaffold to create a scaffolding for the database table catalogs. A Variable input dialog prompts for a value for the Model name. Specify a model name, ‘catalog’ for example. A Variable input dialog prompts for a Controller name. Specify a controller name, ‘catalog’. -
In the Variable Input frame, specify catalog as the model name
2007-05-03 13:51:01 pksiv [View]
Thanks. The text is missing some of the $'s so my cut and paste was causing issues.
-
In the Variable Input frame, specify catalog as the model name
2007-05-03 14:09:02 Deepak Vohra | [View]
Select the variables with the Variables button. The ${} gets added to the variables.
-
RadRails
2007-04-27 12:47:57 carlgraff [View]
Yes I have used RadRails for quite awhile but had to drop it in favor of Komodo because the debugging is way screwed up. I think there are 7 open tickets in RDT that have been sitting around for about 3 months preventing the release of the next milestone.
By the look of the activity over at NetBeans they will probably have their version with debugging ready before the next release of RadRails.
Tis a shame because there is so much I liked about RadRails -
RadRails
2007-06-06 09:12:52 kevox [View]
RadRails was purchased recently by Aptana - so development efforts have probably been focussing on integration into Aptana.










For me everything is working fine until I try to create the Model. The script always terminates and I get the message above!
Anyone knows how to fix this? I am running ruby on Linux! I encountered also, that I have a ruby and ruby1.8 in the /usr/bin/ directory...
Thank you for helping in advance!