10

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?

1
  • Rails 3.2.12 - I didn't get any notice about deprecation, neither in app log nor in rspec output
    – Artur79
    Feb 25, 2013 at 14:23

1 Answer 1

23

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")
4
  • assuming by runtime you mean on a per request basis from controller instance Jun 3, 2012 at 2:05
  • Yea I mean, I have no idea what the template path could be at "compile time". It needs to be dynamic and I currently do it in the controller
    – Kirk
    Jun 3, 2012 at 13:11
  • I'll checkout ryans video you posted
    – Kirk
    Jun 3, 2012 at 13:12
  • 12
    Note, that config.paths.app... syntax is deprecated as of Rails 3.1. I believe it should be config.paths['app/views'].unshift...
    – sands
    Apr 28, 2013 at 4:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.