【发布时间】:2015-04-21 22:02:44
【问题描述】:
我正在开发使用条纹支付的应用程序。我的应用程序中有计划和订阅模型。计划有很多订阅,订阅属于 t 计划。在计划索引页面上,我有计划列表,用户可以点击任何计划
<td><%=link_to plan.name, new_subscription_path(:plan_id => plan.id) %></td>
在我的订阅控制器中我有这个
def new
@plan = Plan.find(params[:plan_id])
@subscription = @plan.subscriptions.new
end
def create
@plan = Plan.find(params[:plan_id])
@subscription = @plan.subscriptions.new(subscription_params)
respond_to do |format|
if @subscription.save
format.html { redirect_to @subscription, notice: 'Subscription was successfully created.' }
format.json { render :show, status: :created, location: @subscription }
else
format.html { render :new }
format.json { render json: @subscription.errors, status: :unprocessable_entity }
end
end
end
我正在尝试根据特定计划建立订阅,但我收到此错误
Couldn't find Plan with 'id'=
【问题讨论】:
-
你能添加你的 config/routes.rb 吗?
-
资源:计划,资源:订阅
标签: ruby ruby-on-rails-3