Prev | Current Page 463 | Next

Brad Ediger

"Advanced Rails"

Although it takes up a little more room in the repository and on the
server, it ensures that everyone is on the same page and developing against the exact
same version.
Nothing says that you have to use edge Rails; for the stable branch of Rails 1.2, use
Piston to lock vendor/rails to http://svn.rubyonrails.org/rails/branches/1-2-stable.
Environment Initialization
As Rails has matured, the environment.rb configuration file has been shifting in purpose
and style. Originally, it started out as a procedural language where every little
bit of configuration was included, and you would just ???throw something at the bottom???
to have it run upon Rails initialization. Now, its purpose is more focused, to
the point that it almost seems to be a domain-specific language for configuring Rails.
The mechanics of starting up Rails have been moved to boot.rb, and what is left has
been cleaned up.
However, sometimes we just need a place to put initialization routines. In edge
Rails, these have been given a new place. If you have (or create) a config/initializers
directory, any Ruby files there will be executed after the environment is configured.
312 | Chapter 10: Large Projects
Having a separate place for initializers helps you to separate them by function. Here
is a sample file for custom inflections:
# config/initializers/inflections.rb
# inflect.uncountable(["data"]) doesn't catch "something_data"
Inflector.


Pages:
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475