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
- Click the Generators tab to go to the Generators View.
- From the drop-down list, select Controller.
- Enter the name of the controller you wish to generate, say 'post'
- Click the Go button to generate the Controller script.
This runs the generator script and displays any output in the Console View.
- You will find the generated controller in the location /projectname/app/controllers/controllername_controller.rb
Views
- 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.
- Otherwise, locate the views folder in your project under /projectname/app/views/.
- 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"
- 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:
- Click the Generators tab to go to the Generators View.
- From the drop-down list, select Migration.
- 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:
- In the Rails Navigator View, expand the db > migrate folders for your project.
- Double-click the migration script to open it in an Editor and make the appropriate changes.
- 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:
- Click the Generators tab to go to the Generators View.
- From the drop-down list, select Scaffold.
- 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.