Aptana Studioヘルプ > はじめに > Developing Rails Projects with RadRails > Starting a new RadRails project

Building an application in RadRails

This page gives an overview of how to build an application in RadRails.

Contents

Introduction

Once you have created your project, you can begin adding models, scaffolds, controllers, views, and other items. The most convenient way to do that is to use the Generators view. RadRails provides a graphical interface to the various generator scripts typically called on the command line. For more information, please see Using the Generators View.

Instructions

Before you begin, select your project in the Rails Navigator View.

Controllers

Replaces script/generate controller

  1. Click the Generators tab to go to the Generators View.
  2. From the drop-down list, select Controller.
  3. Enter the name of the controller you wish to generate, say 'post'
  4. Click the Go button to generate the Controller script.

    This runs the generator script and displays any output in the Console View.

  5. You will find the generated controller in the location /projectname/app/controllers/controllername_controller.rb

Views

  1. If you have a controller already created, you can select the "Go to view" button in the top of the toolbar (it's a page with a little 'V'). If your view is not created already, it will ask you if you wish to create one.
  2. Otherwise, locate the views folder in your project under /projectname/app/views/.
  3. Right-click or choose File > New > Folder to create a new folder underneath the views folder. Name it the same as the name of your controller, i.e. if the the controller was named "post_controller.rb", the view folder would be named "post"
  4. Again, right-click or choose File > New > RHTML/ERB to create a new file underneath the folder you just created. You will want to create a file named the same as the action in your controller. Thus, if you have
     def index
        render :text => "Hello World!"
     end

    Your view should be named 'index.rhtml'

Migrations

Replaces script/generate migration. To generate a migration script:

  1. Click the Generators tab to go to the Generators View.
  2. From the drop-down list, select Migration.
  3. Click the Go button to generate the Migration script.

    This runs the generator script and displays any output in the Console View.

Edit the migration script that the generator created:

  1. In the Rails Navigator View, expand the db > migrate folders for your project.
  2. Double-click the migration script to open it in an Editor and make the appropriate changes.
  3. Once you have set up the migration script, you can run it from the Rake Tasks View while you work on your application.

Scaffolds

Replaces script/generate scaffold. Generate a scaffold:

  1. Click the Generators tab to go to the Generators View.
  2. From the drop-down list, select Scaffold.
  3. Click the Go button to generate the Scaffold script.

    This runs the generator script and displays any output in the Console View.

Once done, run your unit tests to see where your application needs troubleshooting. See Running a unit test on RadRails for instructions.

Related Topics