覆盖 ShopifyApp 模块方法
Override ShopifyApp Module Method
我正在尝试覆盖 ShopifyApp's new method 但不确定从哪里开始。基本上我需要添加另一个字段来获得 params
:
/lib/shopify_app/sessions_concern/new.rb:
module ShopifyApp
module SessionsConcern
module New
def new
if params[:field] == "abc"
authenticate if params[:shop].present?
end # or else ...
end
end
end
end
要使用那个模块,我会在控制器中做这样的事情:
ShopifyApp::SessionsConcern.prepend ShopifyApp::SessionsConcern::New
但是没有地方可以使用它。如何以正确的方式解决这个问题?
重写就是重写。以下将在没有任何 prepend
ing 的情况下为您完成(假设您正在从 lib
目录加载代码):
# lib/shopify_monkeypatching.rb
module ShopifyApp
module SessionsConcern
def new
if params[:field] == "abc"
authenticate if params[:shop].present?
end # or else ...
end
end
end
我正在尝试覆盖 ShopifyApp's new method 但不确定从哪里开始。基本上我需要添加另一个字段来获得 params
:
/lib/shopify_app/sessions_concern/new.rb:
module ShopifyApp
module SessionsConcern
module New
def new
if params[:field] == "abc"
authenticate if params[:shop].present?
end # or else ...
end
end
end
end
要使用那个模块,我会在控制器中做这样的事情:
ShopifyApp::SessionsConcern.prepend ShopifyApp::SessionsConcern::New
但是没有地方可以使用它。如何以正确的方式解决这个问题?
重写就是重写。以下将在没有任何 prepend
ing 的情况下为您完成(假设您正在从 lib
目录加载代码):
# lib/shopify_monkeypatching.rb
module ShopifyApp
module SessionsConcern
def new
if params[:field] == "abc"
authenticate if params[:shop].present?
end # or else ...
end
end
end