Ruby on rails 当我使用form_标签时,为什么要问我两个参数
为什么当我尝试发送这三个参数(收件人\电子邮件)时,我收到错误: FreeRegistrationCouponsController#发送中的ArgumentError 参数数目错误(0为2)Rails.root: /用户/regedarek/code/wifiname 应用程序跟踪|框架跟踪|完整跟踪 应用程序/控制器/免费注册\u优惠券\u控制器.rbin`send' 我做错了什么Ruby on rails 当我使用form_标签时,为什么要问我两个参数,ruby-on-rails,ruby-on-rails-3,forms,routes,Ruby On Rails,Ruby On Rails 3,Forms,Routes,为什么当我尝试发送这三个参数(收件人\电子邮件)时,我收到错误: FreeRegistrationCouponsController#发送中的ArgumentError 参数数目错误(0为2)Rails.root: /用户/regedarek/code/wifiname 应用程序跟踪|框架跟踪|完整跟踪 应用程序/控制器/免费注册\u优惠券\u控制器.rbin`send' 我做错了什么 <div class="span6"> <b>Give three of your
<div class="span6">
<b>Give three of your friends a free registration</b>
<%= form_tag :controller => 'free_registration_coupons', :action => "send" do %>
<%= label_tag :recipient_email_1 %>
<%= text_field_tag :recipient_email_1 %>
<%= label_tag :recipient_email_2 %>
<%= text_field_tag :recipient_email_2 %>
<%= label_tag :recipient_email_3 %>
<%= text_field_tag :recipient_email_3 %>
<%= submit_tag %>
<% end %>
</div>
class FreeRegistrationCouponsController < ApplicationController
def send
@sender_id = current_user.id
binding.pry
redirect_to root_path
end
end
resources :free_registration_coupons do
collection do
get 'send'
post 'send'
end
end
给你的三个朋友免费注册
“免费注册优惠券”:操作=>“发送”do%>
类FreeRegistrationCouponsController
不要调用您的操作发送-您正在覆盖核心ruby方法。Rails试图调用这个核心ruby方法,但最终却调用了您的方法,该方法具有不同的签名
Rails可能应该使用
\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
<div class="span6">
<b>Give three of your friends a free registration</b>
<%= form_tag '/free_registration_coupons/send' do %>
<%= label_tag :recipient_email_1 %>
<%= text_field_tag :recipient_email_1 %>
<%= label_tag :recipient_email_2 %>
<%= text_field_tag :recipient_email_2 %>
<%= label_tag :recipient_email_3 %>
<%= text_field_tag :recipient_email_3 %>
<%= submit_tag %>
<% end %>
</div>
给你的三个朋友免费注册
我相信问题在于你的form_标签没有像你包含它们那样期待参数。这很有趣——你能指出关于不能命名动作send
的任何信息吗?核心ruby方法是有文档记录的[如果你查看rails源代码,你可以使用send看到它。过去有一个(模糊地)维护了“坏”操作/模型/方法/类名的列表,但我认为目前没有最新的