Rails And Rake Redux

Okay, so it turned out that reading the rake documentation was helpful as heckfire.

  • Rails generates a rakefile by default. It contains:
  • require File.expand_path('../config/application', __FILE__)

  • File.expand_path retrieves an absolute path. The second argument __FILE__ is the place for expand_path to start searching. This expands to /path/to/rails/app/Rakefile
  • The first argument to expand_path is ‘../config/application’. The .. means “/path/to/rails/app/Rakefile” becomes “/path/to/rails/app”. Then “/config/application” is appended.
  • Once the application config is retrieved, then the task YourAppNameSpace::Application.load_tasks is performed. This loads the rake tasks so that rake -vT can see ’em.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s