AgileDevelopmentOfThePluginPortal Rails2

Agile Development of the Plugin Portal Demo (10 Minutes)

This demo script is part of the NetBeans World Tour 2008 session #3, Introduction to JRuby on Rails.

This Ruby on Rails demo, through a series of iterations, gets a basic application for managing the Plugin Portal, up and running. This demo uses Rails 2.0.2, which is the version that ships with NetBeans 6.1. For Rails 1.2.5 and NetBeans 6.0, please use this version.

Product Versions Supported

NetBeans 6.1

Points to Hit

It's easy to be agile with Rails, especially because of the following features this demo illustrate:
  • Database Migrations
  • Instant Feedback Loop
  • Easy Validation

Demo Prep

The demo steps assume you are using MySQL.

  1. Install MySQL Database Server Community Edition from


None known at this point


Iteration 1: Get Something Running

  • Create a new Ruby on Rails Application named plugin_portal
  • Run Rake Task > DB > Create
  • If using a database user other than root, edit the database.yml file (under Configuration) and specify the MySql username/password on lines 17 and 18. These should be the same as the username/password used to create the database.
  • Generate a scaffold:
  • Model Name: Plugin
  • Attribute Pairs: name:string description:text plugin_url:string
  • Review the Output window for what was created: the views, the model class, a unit test, a test fixture, a migration and a controller. This presentation doesn't have time to get into testing.
  • Open and review the 001_create_plugins migration that was created as part of the scaffold generation.
  • Right-click the project choose Migrate Database > To Current Version
  • Press F6 to start the server and open the browser to: http://localhost:3000/plugins/
  • Click the New plugin button. Add a plugin and then save it.

Iteration 2: Add a Missing Column

We forgot to include the plugin's price

  • Generate a Migration named AddPriceToPlugin price:decimal
  • Use code-completion to add default, precision and scale to the end of the add_column method::
          add_column :plugins, :price, :decimal, :precision => 8, :scale => 2, :default => 0
  • Save and migrate again to the current version.
  • Open new.html.erb and add
    <b>Price</b><br />
    <%= f.text_field :price %>
  • Open show.html.erb and add
  <%=h @plugin.price %>
  • Save all, return to the browser and refresh the page (this is the instant feedback loop developers love)

Iteration 3: Validate!

  1. Switch to the plug-in model and type vp<tab> which expands to validates_presence_of and add :name, :description.
      validates_presence_of :name, :description, :plugin_url
  • Add one for price as well (this is no template for this - yet. For the demo, I create the following template vn - validates_numericality_of :${1 default="attribute"})
      validates_numericality_of :price
  • Similarly we could validate the price is not negative and that the format of the url is correct, but this is beyond the scope of this demo.
  • Test

Next Steps

Debugging the Plugin Portal

Demo Cleanup

These are the necessary steps to take in order to successfully run the demo again on the same machine.

  1. Delete the plugin_portal project
  2. Delete the plugin_portal database
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo