新手问题 这样的功能怎么实现呢?求高人指点

tomwey · June 29, 2012 · Last by tomwey replied at June 29, 2012 · 2216 hits

不同的用户,layout 不一样。比如 admin 和一般的用户登陆系统后,看到的 layout 是不一样的。跪求高人指点一下!!!

给你个 spree 的例子:

class Admin::BaseController < Spree::BaseController
  layout 'admin'
end

class Admin::OrdersController < Admin::BaseController

end

layout 能够用 Proc 作为参数:

class XxxController < ApplicationController
  layout Proc.new { |controller| current_user.admin? ? 'admin' : 'application' }
end

多看看文档吧,这些基础的东西在 rails 文档上都有的

哦,谢谢!我好好看看文档

You need to Sign in before reply, if you don't have an account, please Sign up first.