我正在使用alias_method_chain向控制器添加功能 但无法访问参数。这里params [:email]是零
module Spree::MyExtensionUsersController
def self.included(target)
target.class_eval do
alias_method_chain :create, :extra
end
end
def create_with_extra
#email comes from a form
email = params[:email]
do_something(email)
create_without_extra
end
end
答案 0 :(得分:0)
尝试使用before_filter
:
def self.included(target)
target.send :before_filter, :do_something_with_email, :only => :create
end
def do_something_with_email
#email comes from a form
email = params[:email]
do_something(email)
end