Shoulda - 将参数传递给控制器操作
最近,我在功能测试中将参数传递给控制器操作时遇到了有趣的问题。以前,我像这样传递“类型”参数(STI 需要的)并且它有效:
setup do
get :new, :type => "TimeOfUseTariff"
end
但是事情已经改变,我现在需要传递一些东西[类型]。我已经尝试了以下方法,但似乎没有任何效果:
setup do
get :new, "something[type]" => "TimeOfUseTariff"
end
两者都没有:
setup do
get :new, "something[type]".constantize => "TimeOfUseTariff"
end
有什么方法可以实现传递这个额外的参数吗?
I've recently run into interesting problem passing parameters to my controller action from my functional test. Previously, I was passing the 'type' parameter (which is required by STI) like that and it worked:
setup do
get :new, :type => "TimeOfUseTariff"
end
However things have changed and i now need to pass something[type]. I've tried the following but nothing seems to work:
setup do
get :new, "something[type]" => "TimeOfUseTariff"
end
Neither:
setup do
get :new, "something[type]".constantize => "TimeOfUseTariff"
end
Is there any way how I can achieve passing this extra parameter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果控制器需要“something[type]”,这应该可以工作:
This should work if the controller expects "something[type]":