O'Reilly logo

Crafting Rails 4 Applications, 2nd Edition by José Valim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending Rails with Railties

A Rails::Railtie (pronounced “Rails Rail-tie”) allows you to hook into Rails’s initialization and configure some defaults. Such tools allow frameworks like Active Record to tell Rails how it should be initialized and configured by providing a railtie.

You should include a railtie in your plug-in only if at least one of the following is true:

  • Your plug-in needs to perform a given task while or after the Rails application is initialized.

  • Your plug-in needs to change a configuration value—for instance, setting a generator.

  • Your plug-in must provide Rake tasks and generators in nondefault locations (the default location for the former is lib/tasks, and it’s lib/generators or lib/rails/generators for the latter).

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required