Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prepend rails view paths in rails 3.2 (ActionView::PathSet)

I am trying to prepend views to the rails view array e.g.

prepend_view_path("#{Rails.root}/app/views/custom/blah")

This works fine, however in my test suite I keep seeing

DEPRECATION WARNING: process_view_paths is deprecated and will be removed from Rails 3.2.

After a bit of research I see mention of ActionView::PathSet, but cannot find any help searching google or in the Rails API documentation. I need to know how to use this new way of prepending paths in rails 3.2

I would really like to get rid of this warning. Any thoughts?

like image 754
Kirk Avatar asked Jun 02 '12 16:06

Kirk


1 Answers

If it is dynamic (set on a per-request basis):

class ApplicationController < ActionController::Base
  before_filter :set_view_path

  def set_view_path
    prepend_view_path "#{Rails.root}/app/views/custom/blah"
  end  
end

I think it went to AbstractController::ViewPaths, but still available from controller - should be without deprecation.

If you prepend static fixed path:

# config/application.rb    
config.paths.app.views.unshift("#{Rails.root}/app/views/custom/blah")
like image 195
Viktor Trón Avatar answered Oct 14 '22 13:10

Viktor Trón