在我的軌道項目中,我得到以下錯誤,當我查看/subscription/new
路徑錯誤:軌道3 - 使用的form_for上的資源時
NoMethodError in Subscriptions#new
Showing /redacted/app/views/subscriptions/new.html.erb where line #4 raised:
undefined method `subscriptions_path' for #<#<Class:0x007fd02c8bbb28>:0x007fd0308f7a48>
Extracted source (around line #4):
1: <div class="grid_6">
2: <h1>New Subscription</h1>
3: <p>
4: <%= form_for @subscription, :html => { class: 'form_dark' } do |f| %>
5: <% if @subscription.errors.any? %>
6: <div class="error_messages">
7: <h1><%= pluralize(@subscription.errors.count, "error") %> prohibited this subscription from being saved:</h1>
我的路線文件包含resource :subscription
這一點。
附加代碼信息:
用戶模式:
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me
has_one :subscription
end
訂閱模式:
class Subscription < ActiveRecord::Base
attr_accessible :status, :stripe_token, :user_id, :last_charge, :stripe_card_token
belongs_to :user
has_many :payments, :dependent => :destroy
belongs_to :plan
attr_accessor :stripe_card_token
end
我SubscriptionsController新方法:
def new
@subscription = User.find(current_user.id).build_subscription
end
任何幫助是應用程序調整,謝謝!
是指SessionsController或SubscriptionsController? – cdesrosiers
@cdesrosiers嘿,對不起,我的意思是SubscriptionsController - 必須有頭腦中的會話。修正了,謝謝。 –