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, right-click the project node or a subnode, choose New, and choose the type of file you would like to add.
  2. 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 Rails model, controller, migration, scaffold, and so on
  1. In the Projects window, right-click the Ruby on Rails project node and select Generate to open the Rails Generator dialog box.
  2. Expand the Generate drop-down list and choose the item you would like to generate.
  3. Using the generator's instructions that appear in the scroll box, fill out the form.
  4. Click OK to generate the code. The Output window lists the files that the generator creates and modifies.
Edit files
  1. In the Projects window, double-click the project node to expand it.
  2. Expand the subnodes to navigate to the file that you want to edit, and double-click it to open it in the editor.

You can also use a keyboard shortcut to quickly open a file in the editor. Windows users, press Alt-Shift-O. For Mac users, press Ctrl-Shift-O.

For more information, see Ruby Editor Shortcut Keys and Code Templates.

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)
Migrate a database
  • To migrate a database for a Ruby on Rails project, 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.
Run a Ruby or Rails application from the IDE.
  • Right-click the project node and choose Run from the pop-up 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 that is configured for the project and displays in your default browser.
      • To stop the server, click the X button Red X icon to the left of the output window at the bottom of the IDE.
Run a controller action or view file
  1. If you are in a view file, press Shift-F6 to run the current file. If you are in a controller file, right-click in the action and choose Run File from the pop-up menu.
  2. The IDE starts the web server if it is not already running, and opens the browser on the URL corresponding to the current file. If you are passing data in the URL or are the application uses mapped routes, you might need to rewrite the URL.
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.
  • You can run a unit test by using the Run File or Test File options from the editor pop-up menu.
Debug a Ruby or Ruby on Rails application
  • Choose Debug > Debug Project from the main menu.

For more information, see

Manage your Ruby gems

For more information, see

Manage your Rails plugins
  • To open the Rails Plugins manager, right-click a Ruby on Rails project node in the Projects window and choose Rails Plugins.
Run Rake tasks
  1. Right-click the project node and choose Run/Debug Rake Task from the pop-up menu.
  2. Optionally, enter a few characters in the Filter textbox to filter the list. You can use the ? and * wildcards.
  3. Select the task that you want to run.
  4. If the task takes parameters, you can enter them in the Parameters textbox. The IDE remembers the parameters from the last time you ran the same task.
  5. Click Run.

For more information, see

Use the interactive Ruby shell (irb) in the IDE
  • To open an interactive Ruby (IRB) shell in the IDE, right-click a Ruby or Ruby on Rails project node in the Projects window and choose Ruby Shell (IRB) from the pop-up menu.

The IRB shell opens in a tabbed window at the bottom of the IDE in the same location as the Output window. The IDE looks at project's Ruby Platform setting in the Properties manager to determine which interpreter to use. The window's tab shows which interpreter is used.

Open a Rails Console
  • Right-click a Ruby on Rails project node and choose Rails Console from the pop-up menu.
Change Project Settings
  • To change a project's settings, such as Ruby interpreter, web server, or Rails environment, right-click the project node and choose Properties from the pop-up menu to open the Properties manager.

You can set up multiple configurations for a project. Open a project's Properties manager and click New to create a new configuration. To change from one configuration to another, right-click the project node and choose Set Configuration.

See Also
About Ruby Development in the NetBeans IDE

Legal Notices