ianwhite / inherit_views >>info >>api
inherit_views works with rails 2.x
If you're on rails 2.3 or rails edge, you want inherit_views/master
If you're on rails 2.2, you want inherit_views/rails-2.2
If you're on rails 2.0, or 2.1, you want inherit_views/rails-2.0-2.1
what does it do?
This rails plugin allows your controllers/mailers to inherit their views from parent controllers/mailers. The default behaviour is to inherit along the ancestor path of the controller/mailer, but you can also specify custom inherit view paths to search.
class ApplicationController < ActionController::Base inherit_views end class FooController < ApplicationController # will look for views in 'views/foo', then 'views/application' end class BarController < FooController # will look for views in 'views/bar', then 'views/foo', then 'view/application' end
See InheritViews for more details
NOTE: this plugin is not aimed at having multiple view paths for your controllers, which is addressed with the view_paths addition to ActionController::Base for rails 2.0. Rather, within these view paths, you can inherit views from other controller paths.
You can render the 'parent' template from within a template if you so choose. This works for partials and top-level templates alike.
<%= render :parent %> <h2>With some 'bar' action</h2>
rendering bar/view (with the controller setup described above):
<h1>Foo View</h1> <h2>With some 'bar' action</h2>
You can install inherit_views as either a plugin or a gem. The easiest method is to install as a plugin by running the following command in your Rails project's top level directory:
ruby script/plugin install git://github.com/ianwhite/inherit_views.git
This method will install the plugin into [RAILS PROJECT HOME]/vendor/plugins.
If you find yourself installing inherit_views into many projects a better alternative is to install the plugin as a gem so that it can be used in any Rails application (this requires RubyGems).
sudo gem install ianwhite-inherit_views
Then, in your project's environment.rb, add the line below following Rails::Initializer.run do |config|.
config.gem 'ianwhite-inherit_views', :lib => 'inherit_views'
Then restart your sever!
Testing & CI
RSpec is used for testing, so the tests are in spec/ rather than test/ Do rake –tasks for more details.
garlic is used for CI, see garlic.rb for details on what versions of rails are tested.
Author: Ian W. White