1

i've got controllers/admin/base_controller.rb where defined all similar actions (with help of inherited_resources gem) for other admin controllers (they are called like class Admin::EventsController < Admin::BaseController) and i'm almost happy - controllers are empty in 50%, but i found myself duplicating views which are commonly four: index.haml, new.haml, edit.haml, _form.haml. only _form looks different, others are 2 lines of code and duplicated like 15 times already! i tried to delete views/admin/events/index.haml and place it to views/admin/base/index.haml, but rails does not include it in template search paths:

Template is missing

Missing template admin/events/index with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml, :haml], :formats=>[:html], :locale=>[:ru, :ru]} in view paths "/home/nir0/projects/vsluh/app/views", "/home/nir0/.gems/ruby/1.9.1/gems/event-calendar-2.3.3/app/views", "/home/nir0/.gems/ruby/1.9.1/gems/ckeditor-3.5.3/app/views", "/home/nir0/.gems/ruby/1.9.1/gems/devise-1.2.1/app/views"

how do i add it on controller level? i found info about TEMPLATE_ROOT, but it's constant and deprecated. also tried

ActionView::Base.new do |av| av.base_path.add = "#{RAILS_ROOT}/app/views/admin/base" end

with no success

the goal is to delete index, new and edit views, which are all the same but titles and objects, which can be carried by i18n and inherited_resources

nir0
  • 529
  • 4
  • 7

0 Answers0