Prev | Current Page 465 | Next

Brad Ediger

"Advanced Rails"


In the environment.rb file, inside the Rails::Initializer.run block, add the
following:
config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir|
File.directory?(lib = "#{dir}/lib") ? lib : dir
end
* http://errtheblog.com/post/2120
Project Structure | 313
There are plenty of nuances to this trick, so be sure to check the aforementioned blog
post and its comments for the full story.
Multi-Application Projects
For large projects, sometimes multiple Rails applications need to be grouped
together. Multiple applications that need to share code can be grouped in the same
version control tree. This is a good use for Subversion externals; externals can point
to other parts of the repository that they live in.
Under this setup, bits of shared code are kept in the repository at the top level of
their branch or trunk (at the same level as the Rails applications). Subversion externals
are used to pull shared folders into each of the Rails projects. A typical directory
structure looks like Figure 10-5.
Under this directory layout, you would issue commands like the following to import
each directory from the shared tree:
$ cd project
$ svn propset svn:externals "models (repo)/trunk/shared_models" \
trunk/rails_app_{1,2}/app
That command tells Subversion to source trunk/rails_app_1/app/models and trunk/
rails_app_2/app/models from trunk/shared_models. When you update either of the Rails
applications, they will grab code from shared_models.


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