我已经定义了我的ApplicationController以下内容:
class ApplicationController < ActionController::Base
before_action :set_shop
attr_reader :current_shop
protected
def set_shop
if params[:shop].present?
@current_shop ||= Shop.find_by(domain: params[:shop])
else
@current_shop ||= Shop.find_by(domain: request.headers['HTTP_X_SHOPIFY_SHOP_DOMAIN'])
end
end
end
另一个继承自的控制器ApplicationController
class V1::CcsController < ApplicationController
def test_ccs
current_shop
@current_shop
byebug
end
end
我的文件夹结构很好,意思ApplicationController是不在V1文件夹CcsController中。
某些原因可能很简单,我无法访问current_shop. 我确实确保正在设置 current_shop。
那么我怎样才能访问current_shop我的CcsController?