我正在尝试通过和编辑页面更新我的条带订阅,但它似乎不喜欢我扔给它的任何东西。
这是我的路线.rb
get 'subscribe' => 'subscribe#stepone'
get 'subscribe/sliding-scale' => 'subscribe#steptwo'
get 'subscribe/sliding-scale/subscriber' => 'subscribe#subscriber'
get 'subscribe/sliding-scale/supporter' => 'subscribe#supporter'
get 'subscribe/sliding-scale/sustainer' => 'subscribe#sustainer'
post 'subscribe/sliding-scale/:type' => 'subscribe#createSubscription'
get 'subscribe/edit' => 'subscribe#edit', :as => :edit_subscription
match '/subscribe/edit', to: 'subscribe#deleteCard', via: :delete
match '/subscribe/edit', to: 'subscribe#updateSubscription', via: :post
post 'subscribe/edit/changeSubscription' => 'subscribe#changeSubscription', :as => :change_subscription
我的订阅控制器:
def changeSubscription
customer = Stripe::Customer.retrieve(@user.stripeCustomerId)
@plan = params[:plan]
@user.update_subscription(:plan => @plan, :prorate => true)
current_role = @user.roles.first.name
@user.remove_role current_role
current_user.add_role params[@plan]
end
最后是我的编辑视图:
<h2>Change My Subscription</h2>
<h3>Your current plan is: <%= current_user.roles.first.name %>
<%= select_tag @plan, options_for_select([['Subscriber'], ['Sustainer'], ['Supporter']]) %>
<%= link_to "Update", change_subscription_path, :confirm => "You sure?", :plan => @plan %>
我正在尝试将新计划发送到控制器以更新本地角色和计划,但似乎无法找到正确的路径来执行此操作。不知道我在这方面做错了什么。
谢谢你的帮助!