2017-03-25 8 views
0

私はthis documentationのShoppe gemを使って自分のアプリでカート/チェックアウトを作成しようとしています。私はドキュメントの中にあるすべてのコードを持っていますが、orders#checkoutページの "Checkout"ボタンを押すと何も起こりません。ここorders_controllerです:ページが送信時にリダイレクトされない(Shoppe Checkout with Rails)

class OrdersController < ApplicationController 
    def destroy 
     current_order.destroy 
     session[:order_id] = nil 
     redirect_to root_path, :notice => "Basket emptied successfully." 
    end 

    def checkout 
     @order = Shoppe::Order.find(current_order.id) 
     if request.patch? << USING BYEBUG, THIS CONDITION IS FALSE 
     if @order.proceed_to_confirm(params[:order].permit(:first_name, :last_name, :billing_address1, :billing_address2, :billing_address3, :billing_address4, :billing_country_id, :billing_postcode, :email_address, :phone_number)) 
      redirect_to checkout_payment_path 
     end 
     end 
    end 

    def payment 
     if request.post? 
     redirect_to checkout_confirmation_path 
     end 
    end 

    def confirmation 
     if request.post? 
     current_order.confirm! 
     session[:order_id] = nil 
     redirect_to root_path, :notice => "Order has been placed successfully!" 
     end 
    end 
end 

そして、ここでは私のorders/checkout.html.erbの内容です:

<div class="container"> 
    <h2 class="text-center">Checkout</h2> 

    <%= render 'items', :order => @order %> 

    <h2 style="margin-top: 50px">Billing Information</h2> 

    <div class="blue-box text-center"> 
     <%= form_for @order, :url => checkout_path do |f| %> 
      <div class="form-group col-xs-6 text-left"> 
      <%= f.label :first_name, 'First Name' %> 
      <% if current_user && current_user.first_name %> 
       <%= f.text_field :first_name, required: true, class: 'form-control', value: current_user.first_name %> 
      <% else %> 
       <%= f.text_field :first_name, class: "form-control" %> 
      <% end %> 
      </div> 
      <div class="form-group col-xs-6 text-left"> 
       <%= f.label :last_name, 'Last Name' %> 
       <% if current_user && current_user.last_name %> 
        <%= f.text_field :last_name, required: true, class: 'form-control', value: current_user.last_name %> 
       <% else %> 
        <%= f.text_field :last_name, class: "form-control" %> 
       <% end %> 
      </div> 

      <div class="form-group col-xs-12 text-left"> 
       <%= f.label :billing_address1, 'Address' %> 
       <%= f.text_field :billing_address1, class: "form-control", placeholder: "Line 1" %> 
       <%= f.text_field :billing_address2, class: "form-control", placeholder: "Line 2" %> 
       <%= f.text_field :billing_address3, class: "form-control", placeholder: "Line 3" %> 
       <%= f.text_field :billing_address4, class: "form-control", placeholder: "Line 4" %> 
      </div> 

      <div class="form-group col-xs-6 text-left"> 
       <%= f.label :billing_postcode, 'Zip/Post Code' %> 
       <%= f.text_field :billing_postcode, class: "form-control" %> 
      </div> 
      <div class="form-group col-xs-6 text-left"> 
       <%= f.label "Country" %> 
       <%= f.collection_select :billing_country_id, Shoppe::Country.ordered, :id, :name, :include_blank => true %> 
      </div> 

      <div class="form-group col-xs-6 text-left"> 
       <%= f.label :email_address %> 
       <% if current_user && current_user.email %> 
        <%= f.text_field :email_address, required: true, class: 'form-control', value: current_user.email %> 
       <% else %> 
        <%= f.text_field :email_address, class: "form-control" %> 
       <% end %> 
      </div> 
      <div class="form-group col-xs-6 text-left"> 
       <%= f.label :phone_number %> 
       <% if current_user && current_user.phone %> 
        <%= f.text_field :phone, required: true, class: 'form-control', value: current_user.phone %> 
       <% else %> 
        <%= f.text_field :phone_number, class: "form-control" %> 
       <% end %> 
      </div> 
       <%= f.submit 'Continue', class: "btn cta" %> 
     <% end %> 
    </div> <!-- blue box --> 

</div> <!-- container --> 

<script type="text/javascript"> 
    $(document).ready(function(){ 
    $(".footer").removeClass("top-shadow-inset"); 
    }); 
</script> 

「アイテムの部分レンダリングされていることは以下の通りですが、それもない他のページに表示されますこの問題が発生している可能性があります。

<table width='100%' border='1' class="cart-table"> 
    <% if order.order_items.count == 0 %> 

    <thead> 
     <tr> 
     <td colspan='5' class="text-center"><h3>You currently have no items in your cart!<br>Check out our <%= link_to "store", products_path %> for some awesome stuff!</h3></td> 
     </tr> 
    </thead> 

    <% else %> 

    <thead> 
     <tr> 
     <td>Quantity</td> 
     <td>Product</td> 
     <td>Sub-Total</td> 
     <td>Tax</td> 
     <td>Total</td> 
     </tr> 
    </thead> 
    <tbody> 
     <% order.order_items.each do |item| %> 
     <tr> 
     <td><%= item.quantity %></td> 
     <td><%= item.ordered_item.full_name %></td> 
     <td><%= number_to_currency item.sub_total %></td> 
     <td><%= number_to_currency item.tax_amount %></td> 
     <td><%= number_to_currency item.total %></td> 
     </tr> 
     <% end %> 

     <% if order.delivery_service %> 
     <tr> 
     <td></td> 
     <td><%= order.delivery_service.name %></td> 
     <td><%= number_to_currency order.delivery_price %></td> 
     <td><%= number_to_currency order.delivery_tax_amount %></td> 
     <td><%= number_to_currency order.delivery_price + order.delivery_tax_amount %></td> 
     </tr> 
     <% end %> 
    </tbody> 

    <tfoot> 
     <tr> 
     <td colspan='4' class="text-right">Sub-Total</td> 
     <td><%= number_to_currency order.total_before_tax %></td> 
     </tr> 
     <tr> 
     <td colspan='4' class="text-right">Tax</td> 
     <td><%= number_to_currency order.tax %></td> 
     </tr> 
     <tr> 
     <td colspan='4' class="text-right">Total</td> 
     <td><%= number_to_currency order.total %></td> 
     </tr> 
    </tfoot> 

    <% end %> 
</table> 

誰でもこの問題の原因を確認できますか?そこには、関連するコンソールエラーはありませんし、私はチェックアウトをクリックしたときに私のサーバーは、非常に冗長です:

Started PATCH "/checkout" for ::1 at 2017-03-25 11:12:40 -0700 
Processing by OrdersController#checkout as HTML 
    Parameters: {"utf8"=>"✓", "authenticity_token"=>"BFvhlQYmGP2LBLKcrvCsJ0oTdg+Qh7KcGWRPh3YhmBfEIwW+a4VrrxmsaIbY1Yn2Kl4Yt4vbNt+dM4NKY7LZ/w==", "order"=>{"first_name"=>"Liz", "last_name"=>"Bayardelle", "billing_address1"=>"", "billing_address2"=>"", "billing_address3"=>"", "billing_address4"=>"", "billing_postcode"=>"", "billing_country_id"=>"", "email_address"=>"[email protected]", "phone"=>"949-939-0622"}, "commit"=>"Continue"} 
    Shoppe::Order Load (0.1ms) SELECT "shoppe_orders".* FROM "shoppe_orders" WHERE "shoppe_orders"."id" = ? LIMIT 1 [["id", 2]] 
    Shoppe::OrderItem Load (0.2ms) SELECT "shoppe_order_items".* FROM "shoppe_order_items" WHERE "shoppe_order_items"."order_id" IN (2) 
    Shoppe::Product Load (0.2ms) SELECT "shoppe_products".* FROM "shoppe_products" WHERE "shoppe_products"."id" IN (1, 2) 
    CACHE (0.0ms) SELECT "shoppe_orders".* FROM "shoppe_orders" WHERE "shoppe_orders"."id" = ? LIMIT 1 [["id", 2]] 
Unpermitted parameter: phone 
    (0.1ms) begin transaction 
    Shoppe::OrderItem Load (0.1ms) SELECT "shoppe_order_items".* FROM "shoppe_order_items" WHERE "shoppe_order_items"."order_id" = ? [["order_id", 2]] 

    ... 

    (0.1ms) rollback transaction 
    (0.1ms) SELECT COUNT(*) FROM "shoppe_order_items" WHERE "shoppe_order_items"."order_id" = ? [["order_id", 2]] 
    Shoppe::Product::Translation Load (0.1ms) SELECT "shoppe_product_translations".* FROM "shoppe_product_translations" WHERE "shoppe_product_translations"."shoppe_product_id" = ? [["shoppe_product_id", 1]] 
    Shoppe::Product Load (0.1ms) SELECT "shoppe_products".* FROM "shoppe_products" WHERE "shoppe_products"."parent_id" = ? [["parent_id", 1]] 
    ... 

    Rendered orders/_items.html.erb (64.8ms) 
    User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]] 
    Shoppe::Country Load (0.8ms) SELECT "shoppe_countries".* FROM "shoppe_countries" ORDER BY "shoppe_countries"."name" ASC 
    Rendered orders/checkout.html.erb within layouts/application (77.2ms) 
    Rendered layouts/_cart_text.html.erb (1.0ms) 
Completed 200 OK in 200ms (Views: 177.9ms | ActiveRecord: 4.1ms) 

答えて

0

許可されていないパラメータ:携帯電話、あなたのコントローラでこの属性を許可する必要があり

+0

ありがとうヒントのために。私はページのその部分を削除しました(不要な機能性)ので、 ':phone'は決して言及されません、':phone_number'だけです。残念ながら、問題は続く... – Liz

+0

まったく同じエラーメッセージがありますか?パラメータ – user426264

+0

を許可する必要がある場合は、 ':phone'のサーバログエラーはなくなりますが、エラーの動作は同じです。 – Liz

関連する問題