Component を実現。
結局、ActionController::Base のClassメソッドである view_paths=(*paths) を使えばよいと。
# /plugin/webjourney/lib/webjourney/widgets/is_component_page.rb module WebJourney module Widgets module IsComponentPage def self.append_features(base) super base.extend(ClassMethods) end module ClassMethods # is_component_page DSL. def is_component_page(options = {}) self.send :view_paths=, [File.join(RAILS_ROOT, "app/views"), File.join(RAILS_ROOT, "components", self.controller_path, "../..")] self.send :include, WebJourney::Widgets::IsComponentPage::InstanceMethods self.send :init_gettext, self.to_s.underscore.split("/").first self.send :layout, :select_layout if options[:title] self.send :before_filter do |controller| controller.assigns[:title] = options[:title] end end end .. (snip) .. end end end end
template_root=(root) が view_paths=(*attr) に変わって、ビューファイルを検索するルートディレクトリを複数指定できるようになっていましたと。配列の先頭から検索しにいく。ここで RAILS_ROOT/components を指定しておけば1.2以前のComponentと同じMVCパスでいける。
で、こっちはいいんだけど、ActionMailer::Base の方は相変わらず template_root=(root) というオチ。