samedi 20 juin 2015

Rails wrong number of arguments (1 for 0), ArgumentError in SubscribeController#update

I created a subscribe section using stripe. But I am having an issue with the routing. I'm not sure whats happening or what to do. Any help would be appreciated

Migration to User Model

class AddExtraDetailsToUser < ActiveRecord::Migration
  def change
      add_column :users, :subscribed, :boolean, :default => false
      add_column :users, :stripeid, :string
  end
end

Routes.rb

Rails.application.routes.draw do

    resources :subscribe

    devise_for :users do
        resources :posts 
        resources :products
    end

    get 'users/:id' => 'users#show', as: :user

end

Subscribe.rb

class SubscribeController < ApplicationController
    before_action :authenticate_user!


    def new
    end

    def update
        token = params [:stripeToken]
        customer = Stripe::Customer.create(
            :card => token,
            :plan => 2,
            :email => current_user.email               
        )

        current_user.subscribed = true
        current_user.stripeid = customer.id
        current_user.save

        redirect_to current_user_path, :notice => "Subscription created"
    end    
end

subscribe.html.erb

<%= form_tag subscribe_path(1), :method => :put do %>

<article>

    <label class="amount">
        <span> Amount: $27</span>

    </label>

</article>



  <script
    src="http://ift.tt/1doUtf9" class="stripe-button"
    data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
    data-amount="2700"
    data-name="Test"
    data-description="Subscription"
    data-email="<%= current_user.email %>">
  </script>
</form>

<% end %>

Error:

enter image description here

Aucun commentaire:

Enregistrer un commentaire