Getting Started With JRuby on Rails for Sun GlassFish Enterprise Server v3 Prelude

ProcedureCreating the Controller and View

By doing this task, you can create a controller and a default view for your application. The controller handles requests, dispatches them to other parts of the application as necessary, and determines which view to render. The view is the file that generates the output to the browser. In Rails, views are typically written with ErB, a templating mechanism.

  1. Go to the <JRUBY_HOME>/samples/hello directory you created in the previous task.

  2. Create a controller and default view for your application:

    jruby script/generate controller home index

    You should see a controller called home_controller.rb in the hello/app/controllers directory and a view called index.html.erb in the hello/app/views directory.