我正在尝试将参数(useremail,costprojects)
从一个控制器操作传递到另一个控制器操作。
这是控制器代码:
def pdfemail
costprojects = Costproject.find(params[:costproject_ids])
useremail = current_user.email
CostprojectsController.delay.pdfemail2(params: { useremail: useremail, costprojects: costprojects })
redirect_to :back
flash[:notice] = 'An Email containing a PDF has been sent to you!'
end
def self.pdfemail2
@useremail = params[:useremail]
@costprojects = params[:costprojects]
...
但是,我明白了:
wrong number of arguments (1 for 0)
延迟项目显示:
object: !ruby/class 'CostprojectsController'
method_name: :pdfemail2
args:
- :params:
:useremail: somebody@gmail.com
:costprojects:
- !ruby/ActiveRecord:Costproject
attributes:
id: 8
...
感谢您的帮助!
答案 0 :(得分:0)
如果要在重定向到另一个动作时传递一些参数,请使用ActionController :: Parameters:
def search
redirect_to :index, params: { query: params[:q] }
end
http://api.rubyonrails.org/classes/ActionController/Base.html