[RSS]
This document describes using Ruby On Rails 1.2.5 in NetBeans.

Current Release (6.0)

For information on using Ruby on Rails 2.0 in NetBeans, see Creating a Rails 2.0 Ruby Weblog in 10 Minutes, Tor's require_gem Blog Entry, or Information Posted on Nabble.

Please note that many of the screenshots are obsolete and will be updated soon.

To view a demo of the NetBeans Rails support, see Roman's flash demo. For step-by-step instructions to reproduce the demo, see Brian's blog entry, as well as an updated entry using migrations.

Below is a screenshot of everything in action:

http://wiki.netbeans.org/wiki/attach/RubyOnRails/rails-support.jpg

If you would like to use Native Ruby with your Rails application, configure that first (in the Options/Preferences dialog).

Go to the New Project dialog. Locate the Ruby On Rails project type and enter the project name.

http://wiki.netbeans.org/wiki/attach/RubyOnRails/rails-1.png

After you click Finish, the IDE will run the Rails code generator and produce a logical view on top of the Rails file structure. The project view separates controllers from models, views, database migrations, and so on. Here is the logical view of the project:

http://wiki.netbeans.org/wiki/attach/RubyOnRails/rails-2.png

The most important operation we'll be doing is running the Rails code generator. Right-click on the project (or one of the project nodes) and choose Generate.

http://wiki.netbeans.org/wiki/attach/RubyOnRails/rails-0.png

The Generator dialog box is now displayed. Here, you can choose what to generate, as well as how to deal with file conflicts.

http://wiki.netbeans.org/wiki/attach/RubyOnRails/extra-generators.png

Usage information for each generator is displayed in the dialog box.

You can also directly install additional code generators (such as the login generator) from this panel by clicking the Install button.

The output of the code generator is shown in the Output window. The output is also processed so that you can click directly on created files and skipped files in order to display them in the source editor.
Here's how this looks:

http://wiki.netbeans.org/wiki/attach/RubyOnRails/rails-5.png

When editing RHTML files, HTML, RHTML directives, and the embedded Ruby code are highlighted.

http://wiki.netbeans.org/wiki/attach/RubyOnRails/rhtml-editing.png

You can jump between actions and views using the "Goto Action/View" item, which is available in the context menu for both Ruby and RHTML files, as well as bound to Ctrl-Shift-A (Command-Shift-A on the Mac).

WEBrick, the built-in Ruby web server, is automatically started on project creation (as well as on Run, if not already running). There is a WEBrick console window which shows the output of the web server. It will list the requests it has processed, which works similar to the Memory Monitor in NetBeans as it lets you watch your requests fly by.

You can use the Mongrel server as well, just install it via the Gem Manager and restart your server.

http://wiki.netbeans.org/wiki/attach/RubyOnRails/mongrel.png

When you Run your project, the Run action will open the browser on the welcome page of your Rails application. There is no deployment step; the application is already deployed in place. If you click on Run File, it will open the browser on a more specific page; for example, the view page corresponding to the controller you are editing.

http://wiki.netbeans.org/wiki/attach/RubyOnRails/rails-6.png

Hint: Hitting Shift-F6 on any file "executes" it. In Rails, it will open the most relevant URL to the controller, action, view, or helper you are editing. For unit tests, it will execute the unit test. For database migrations, it will migrate to the level of the migration file.

For additional Ruby support, view this wiki page.

You can run Rake Targets by using the Rake Target context menu. The target descriptions are tooltips on the menu items. To refresh the list of targets (if you have installed additional plugins or have edited your Rakefiles), select the Refresh Targets item.

http://wiki.netbeans.org/wiki/attach/RubyOnRails/rake-targets.png

To run Rake Migrations, select "Migrate Database" in the context menu as shown above. Choose "To Current Version" to migrate the database to the most recent level, or choose one of the explicit versions listed.

Work in Progress (6.1)

Information to be posted soon.

Attachments

extra-generators.png Info on extra-generators.png 75561 bytes
mongrel.png Info on mongrel.png 74780 bytes
rails-0.png Info on rails-0.png 26829 bytes
rails-1.png Info on rails-1.png 73054 bytes
rails-2.png Info on rails-2.png 26869 bytes
rails-4.png Info on rails-4.png 27135 bytes
rails-5.png Info on rails-5.png 177331 bytes
rails-6.png Info on rails-6.png 36603 bytes
rails-support.jpg Info on rails-support.jpg 246673 bytes
rake-targets.png Info on rake-targets.png 121708 bytes
rhtml-editing.png Info on rhtml-editing.png 40391 bytes