When developing Devise 2.0 specifications "layout_by_resource" warning warnings

I am using Rails 3.2.0 and Devise 2.0.0.rc2. When I run my specifications, I get an obsolescence warning that I don’t see when I usually start my Rails server.

$ rake .DEPRECATION WARNING: Layout found at "devise" for DeviseController but parent controller set layout to :layout_by_resource. Please explicitly set your layout to "devise" or set it to nil to force a dynamic lookup. (called from realtime at /Users/foo/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310) 

My /app/controllers/application_controller.rb looks like this:

 class ApplicationController < ActionController::Base protect_from_forgery layout :layout_by_resource protected def layout_by_resource if devise_controller? if resource_name == :agent && action_name == 'new' nil elsif resource_name == :admin && action_name == 'new' nil else 'devise' end else 'application' end end end 

Any idea why I see these warnings?

+7
source share
2 answers

If you want to get rid of messages, the easiest solution is to rename the layout template of your application to anything other than devise.html.erb , fe to devise_layout.html.erb . Of course, you tweak the layout_by_resource function to match the new name.

This will stop obsolescence messages in your tests and make them readable.

+6
source

With Rails 3.2, the layout will be automatically validated. When you use the view in the "devise" folder, Rails is smart enough to look for the "devise" layout in the layouts folder. Removing this code will clear the depreciation warnings.

However, this would mean that the administrator and agent resources would use the development layout. I do not know how to fix this white color, having received the same warning about impairment.

+3
source

All Articles