使用hidden_​​field标记时,未定义的局部变量或方法`f'

时间:2018-11-13 09:38:23

标签: ruby-on-rails ruby

我正在遵循一个教程,当我尝试在表单中添加f.hidden_field标签时,会出现此错误。

  

未定义的局部变量或方法'f'

<h1>Signing up for "<%= @subscription.plan.name %>"</h1>

<%= f.hidden_field :paypal_customer_token %>
<%= f.hidden_field :paypal_payment_token %>

<% if @subscription.paypal_payment_token.present? %>
  <H1>Payment has been provided </H1>
<% else %>
  <div class="field">
    <%= radio_button_tag :pay_with, :paypal %>
    <%= label_tag :pay_with_paypal do %>
      <%= image_tag "paypal.png" %>
    <% end %>
    <%= link_to "paypal.png", paypal_checkout_path(:plan_id => @subscription.plan_id) %>
<% end %>

1 个答案:

答案 0 :(得分:5)

要么该教程已损坏,要么您错过了他们这样做的那一行:

<%= form_for @subscription do |f| %>