Working With NetBeans Ruby

See Also

This topic describes common tasks that you can perform with NetBeans Ruby and Ruby on Rails projects that are open in the Projects Window. For more detailed information, click the links in the right column.

To perform this task... Follow these steps
Create a new Ruby or Ruby on Rails project
  1. Choose File > New Project from the main menu to open the New Project wizard.
  2. Select Ruby in the Categories list.
  3. In the projects list, select either Ruby Application or Ruby on Rails Application.
Import an existing Ruby or Ruby on Rails application
  1. Choose File > New Project from the main menu to open the New Project wizard.
  2. Select Ruby in the Categories list.
  3. In the projects list, select either Ruby Application with Existing Sources or Ruby on Rails Application with Existing Sources.
Add files to your project
  1. In the Projects window, select the main project node and right-click it.
  2. Select New and choose the type of file you would like to add.
  3. In the New File wizard, specify the file name, location, and so on as needed, and then click Finish to create the file.
Generate a model, a controller, a migration, an integration test, and so on
  1. In the Projects window, select the main node for your Ruby on Rails project and right-click it.
  2. Select Generate to open the Rails Generator dialog box.
  3. Expand the Generate drop-down list and choose the item you would like to generate.

For examples of generating a model and a controller, see  

Edit files
  1. In the Projects window, select the node for your project and, if necessary, double-click it to open the node.
  2. Navigate to the file you want to edit and double-click it to open it in the editor.

For more information on the editor, see:

Jump between a Rails action (a method in a controller file) and its corresponding view (an .rhtml or .erb file)
  • Ctrl-Shift-A
  • Command-Shift-A (Mac shortcut)
Jump between a test file and its tested file
  • Ctrl-Shift-T
  • Command-Shift-T (Mac shortcut)

For more Editor shortcuts, see   

Choose a database server for a Ruby on Rails project
Migrate a database
  • To migrate a database for a Ruby on Rails project (for example, add tables that you have defined in a model), right-click the main project node in the Projects window and choose Migrate Database > To Current Version.
  • You can also revert the database to an earlier version by choosing one of the other To Version choices.
  • For an example, see  in the tutorial "Creating a Ruby Weblog in 10 Minutes".  
Register a database server
Add a database to the IDE
  • For instructions on adding some common databases, see  in the "Installing and Configuring Ruby Support" web article.
Run a Ruby or Rails application from the IDE.
  1. If your project is not the main one, right-click the project node and choose Set as Main Project.
  2. Click the Run Main Project Run Project button toolbar button or press F6 or choose Run > Run Main Project from the main menu.
    • You see a Ruby project's output in a window at the bottom of the IDE.
    • A Ruby on Rails project runs in the server configured for Rails and displays in your default browser.
      • To stop the server, click the X button Red X icon to the left of the server window at the bottom of the IDE.
Run a controller or view file
  • If you're in a controller or view file, press Shift-F6 to run the current file. Doing so starts the web server unless it's already running, then opens the browser on the URL corresponding to the current file.
Run tests on your project
  • For quick testing when editing a view or controller file, use Ctrl-F6, or Command-F6 on a Mac platform, to run the tests associated with the file.

    For full details on testing Ruby and Rails projects, see

Debug a Ruby on Rails application

If you are using the default JRuby interpreter, you can use only the standard debugger.

If you have changed your interpreter to the native Ruby interpreter, you can use the Fast Debugger.

  • To debug a Ruby on Rails application, choose Run > Debug Main Project from the main menu.

    For more information, see the following links:

    • The "Debugging and Testing" links at
Deploy a JRuby application
  • See     in Installing and Configuring Ruby Support.
Manage your Ruby gems
Manage your Rails plugins
Run Rake tasks
  1. In the Projects window, select the name of your project and right-click it.
  2. Select Run Rake Task and choose the type of task you would like to run.
  3. Check the progress of the task in the Output window at the bottom of the IDE.
Use the interactive Ruby shell (irb) in NetBeans
See Also
About Ruby Development in NetBeans

Legal Notices