CSC/ECE 517 Fall 2011/ch2 2f mm: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 16: Line 16:
Rails 3 does away with all of these scripts and compiles them all into a single script named <tt>rails</tt>. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed <tt>'''rails'''</tt> command (ex, <tt>/usr/bin/rails</tt> on Linux systems) in the root of any Rails 3 application, it will know to call this script.
Rails 3 does away with all of these scripts and compiles them all into a single script named <tt>rails</tt>. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed <tt>'''rails'''</tt> command (ex, <tt>/usr/bin/rails</tt> on Linux systems) in the root of any Rails 3 application, it will know to call this script.


==Gem Dependencies==


The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the <tt>config/environment.rb</tt> file had to be edited in order to tell the Rails application to require specific Gems using the <tt>'''config.gem'''</tt> method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the <tt>rake gem:install</tt> command.
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named <tt>Gemfile</tt> in the root of the application as well as the Bundler. The Bundler looks at the contents <tt>Gemfile</tt> and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.


=References=
=References=

Revision as of 03:56, 21 September 2011

Introduction

Rails 2 vs. Rails 3

A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.

Rails Application Scripts

When you create a new Rails application, a directory named script is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows<ref>Ruby 2009, pp 257-258 </ref>:

  • generate: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.
  • destroy: Used to destroy code created by the generate method.
  • server: Starts up the Rails application in a self-contained web server.
  • plugin: Helps with the installation and administration of plug-ins to the Rails framework.
  • performance directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.

Rails 3 does away with all of these scripts and compiles them all into a single script named rails. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed rails command (ex, /usr/bin/rails on Linux systems) in the root of any Rails 3 application, it will know to call this script.

Gem Dependencies

The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the config/environment.rb file had to be edited in order to tell the Rails application to require specific Gems using the config.gem method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the rake gem:install command.

Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named Gemfile in the root of the application as well as the Bundler. The Bundler looks at the contents Gemfile and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.

References

Citation Notes

<references/>

Full Reference Information

Ruby, Sam, Dave Thomas and David Hansson. Agile Web Development with Rails: Third Edition: The Pragmatic Programmers LLC, 2009.