Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Real-Life Rails: Develop with NetBeans, Deploy on Linux : Page 2

Find out how to leverage the Ruby and Rails support in NetBeans 6.0, and then learn some techniques for deploying Rails applications on a Linux server efficiently.


advertisement
Leveraging NetBeans 6.0 Ruby and Rails Support
The first step toward using NetBeans 6.0 for your Ruby and Rails development is installing NetBeans and the Ruby plugins. Click here to download the Ruby NetBeans version 6.0 bundle I use. Add any optional Ruby and Rails plugins (e.g., if you use JRuby and want to add GlassFish plugins) by running the menu item Tools→Plugins.

Although I do use JRuby for projects that use existing Java libraries (for me, this is mostly artificial intelligence development where I need Java libraries for machine learning, reasoning, the semantic web, etc.), I still use the C version of Ruby for almost all Rails development and deployment. By default the Ruby NetBeans 6.0 bundle sets JRuby as the Ruby system. Change this setting by using the menu item NetBeans→Preferences→Ruby (see Figure 1 for a screenshot from my MacBook. If you use Linux or Windows, you will see something similar.).

Next, you will use the Rails Generator in NetBeans to make your development environment as convenient as possible. Figure 2 shows my Rails CookingSpace.com project (and a few other projects that are collapsed from view while I work on CookingSpace.com). When I right-click on the top-level project (or control-click on a Mac), NetBeans displays a popup tools menu with the standard NetBeans tools on the bottom and the Ruby- and Rails-specific tools added to the top. The top option (Generate...) launches Rails Generator.




Figure 1. Change Default Ruby System for Ruby NetBeans 6.0 Bundle: By default the Ruby NetBeans 6.0 bundle sets JRuby as the Ruby system.
 
Figure 2. NetBeans Popup Tools Menu: Here's a screenshot of my Rails CookingSpace.com project.

I find this popup tools menu more convenient than keeping a shell window open to use the Rails command line utilities. Figure 3 shows the Rails Generator dialog box.

You should now have NetBeans and the Ruby plugins installed and ready to go.


Figure 3. Rails Generator Dialog: Here's a screenshot of my Rails CookingSpace.com project.
 
Figure 4. NetBeans Options for Running Tests Inside the IDE: The Ruby and Rails plugins have menu options for running tests inside the IDE.

If you are new to NetBeans, it may take you a while to get used to the environment. To shorten that process, use the following usage tips:

 
Figure 5. Test Server and Rails Console Running at the Same Time: The panel in the lower right corner has both server and console (currently selected) tabs.
  1. Check out the NetBeans web site's one page summary of keyboard shortcuts.

  2. Make use of the Ruby and Rails plugins' menu options for running tests inside the IDE, which I find more convenient than using the command line rake tools (see Figure 4).

  3. One of the most useful techniques for interactively developing a Rails web application using NetBeans 6.0 is to run both a test server (WEBrick or Mongrel) and a Rails console at the same time. As you edit and save code you see the changes testing in a web browser on the test server and you can test snippets of code before adding them to your models or controllers. Meanwhile, the console enables you to inspect live data. See Figure 5 for an example of this setup where the panel in the lower right corner has both server and console (currently selected) tabs.

Before proceeding with this article, now would be a good time to either create a trivial test Rails application using your new NetBeans development setup or import an existing Rails application that you have already written. You can import an existing Rails web application by using the menu File→New Project→Ruby→Ruby on Rails Project with Existing Sources.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap