Rails Scripts

Rails provides us some excellent tools that are used to develop Rails application. These tools are packaged as scripts from command line.

Following are the most useful Rails scripts used in Rails application:

  • Rails Console
  • WEBrick Web Server
  • Generators
  • Migrations

Rails Console

The Rails console is as command line utility which runs Rails application from the command line. The Rails console is an extension of Ruby irb. It provides all the features of irb along with the ability to auto-load Rails application environment, including all its classes and components. It helps you to walk through your application step-by-step.

WEBrick Web server

Rails is configured to automatically use WEBrick server. This server is written in pure Ruby and supports almost all platforms like Windows, Mac or Unix. Alternatively, if you have Mongrel or lighttpd server installed in your system, Rails uses either of those servers.

All the three Rails servers feature automatic reloading of code. It means, when you change your source code, you do not need to restart the server.

Generators

The Rails include code generation scripts, which are used to automatically generate model and controller classes for an application. Code generation increases your productivity when developing Web applications. By running generator command, skeleton files for all your model and controller classes will be generated. It also generates, database migration files for each model it generates.

Migrations

Migrations bring Rails DRY feature to life. It is a pure Ruby code that define the structure of a database. You don’t have to use SQL to write your code while using migration.

The changes you make to your database schema is isolated in a separate migration file, which has a method to implement or reverse the change.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *