Ruby on rails 某些控制器的Rails3布局未渲染
这是我的应用程序_controller.rbRuby 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
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的一些方法而不是创建一个新的