Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 某些控制器的Rails3布局未渲染_Ruby On Rails_Ruby_Ruby On Rails 3_Ruby On Rails 3.2_Ruby On Rails 3.1 - Fatal编程技术网

Ruby on rails 某些控制器的Rails3布局未渲染

Ruby on rails 某些控制器的Rails3布局未渲染,ruby-on-rails,ruby,ruby-on-rails-3,ruby-on-rails-3.2,ruby-on-rails-3.1,Ruby On Rails,Ruby,Ruby On Rails 3,Ruby On Rails 3.2,Ruby On Rails 3.1,这是我的应用程序_controller.rb class ApplicationController < ActionController::Base layout :my_layout private def my_layout request.path.match(/folder/) ? 'layout1' : 'layout2' end end class Post::PromotionsController < ApplicationController

这是我的应用程序_controller.rb

class ApplicationController < ActionController::Base
 layout :my_layout
 private
 def my_layout
   request.path.match(/folder/) ? 'layout1' : 'layout2'
 end
end
class Post::PromotionsController < ApplicationController
  def index
  end
end
class ApplicationController
在该控制器中,默认布局方法称为和layout2 render post/promotion\u controller.rb

class ApplicationController < ActionController::Base
 layout :my_layout
 private
 def my_layout
   request.path.match(/folder/) ? 'layout1' : 'layout2'
 end
end
class Post::PromotionsController < ApplicationController
  def index
  end
end
class Post::PromotionsController
但在此控制器中,未调用user/users\u request\u controller.rb布局方法,也未进行布局渲染

class User::UserRequestsController < User::UserController
 def index
 end
end

class User::UserController < ApplicationController
      def index
      end
end
class User::UserRequestsController
请帮助我为什么没有调用我的布局方法。
我正在使用rails3.2.14和ruby 1.9.3p392

尝试将my_布局方法声明为受保护而非私有


这可能会起作用

您是从
User::UserController
中的
ApplicationController继承的吗?是的,我将User::UserController继承到ApplicationController为什么User::userrequests controller子类User::UserController而不是ApplicationController?这里我使用了User::UserController的一些方法而不是创建一个新的