我需要找出如何設置一個form_for嵌套的路由,所以我可以在一個隱藏的字段中傳遞條形標記。對於文檔我已閱讀並看着我的form_for設置看起來是正確的,但我正在上線這個錯誤開始的form_for:爲條紋形式嵌套的資源表格
undefined method `membership_program_path' for #<#<Class:0x007fd4ef3da588>:0x007fd4f34ccf28>
這裏是我的路線:
resources :programs, except: [:show] do
resources :memberships, only: [:new, :create]
end
我會員控制器:
def new
@membership = Membership.new
@program = Program.find(params[:program_id])
end
這裏是我的整個_form.html.erb
<%= form_for [@membership, @program] do |f| %>
<%= f.hidden_field :stripe_card_token %>
<div class="field">
<%= f.label :email %>
<%= f.text_field :email %>
</div>
<% if @members.stripe_card_token.present? %>
Credit card has been provided.
<% else %>
<div class="field">
<%= label_tag :card_number, "Credit Card Number" %>
<%= text_field_tag :card_number, nil, name: nil %>
</div>
<div class="field">
<%= label_tag :card_code, "Security Code on Card (CVV)" %>
<%= text_field_tag :card_code, nil, name: nil %>
</div>
<div class="field">
<%= label_tag :card_month, "Card Expiration" %>
<%= select_month nil, {add_month_numbers: true}, {name: nil, id: "card_month"} %>
<%= select_year nil, {start_year: Date.today.year, end_year: Date.today.year+15}, {name: nil, id: "card_year"} %>
</div>
<% end %>
<div id="stripe_error">
<noscript>JavaScript is not enabled and is required for this form. First enable it in your web browser settings.</noscript>
</div>
<%= f.submit %>
<% end %>
扔你的路線(耙路線),並顯示這是特定的部分。我懷疑它可能是一對一的關係,資源與路線文件中的資源。 –