Slowboy Slowboy - 1 month ago 11
Ruby Question

suddenly getting a 'wrong number of arguments (1 for 0)' in order_form

The problem is that my app was working perfectly just an hour ago, then I added two columns (:pick_up and :send) to the 'orders' table.

and after that I´m getting this error

wrong number of arguments (1 for 0)


I can't see why that should be causing this error though.

The thing is I can´t see anything wrong with my code, can anyone take a look at this and see why this is suddenly not working

here is the
orders_controller.rb


class OrdersController < ApplicationController

include CurrentCart
before_action :set_cart, only: [:new, :create]
before_action :set_order, only: [:show, :edit, :destroy]

def index
@orders = Order.all?
end

def new
@images = ["1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"]
@random_no = rand(5)
@random_image = @images[@random_no]

if @cart.product_items.empty?
redirect_to root_url, notice: 'Your Cart is Empty'
return

end
@order = Order.new
@client_token = Braintree::ClientToken.generate
end

def create
@order = Order.new(order_params)
if @order.save
charge
if @result.success?
@order.add_product_items_from_cart(@cart)
Cart.destroy(session[:cart_id])
session[:cart_id] = nil
OrderNotifier.received(@order).deliver
redirect_to root_url, notice: 'Thank You for Your Order'
else
flash[:error] = 'Please Check Your Cart'
redirect_to root_url, alert: @result.message
@order.destroy
end
else
@client_token = Braintree::ClientToken.generate
render :new
end
end


def show

end


def destroy
@order.destroy
redirect_to root_url, notice: 'Order deleted'
end

private

def set_order
@order = Order.find(params[:id])
end

def order_params
params.require(:order).permit(:name, :email, :address, :city, :country, :pick_up, :send)
end

def charge
@result = Braintree::Transaction.sale(
amount: @cart.total_price_usd,
payment_method_nonce: params[:payment_method_nonce] )
end

end


this is the
_form.html.erb
for the orders.

<%= form_for @order do |f| %>
<%= render 'msg' %>

<div class="container">
<div class="col-md-10">
<h3>Please Enter Your Details</h3>
</div>


<div class="form-group">
<div class="col-md-10">
<%= f.label :name %>
<%= f.text_field :name, size: 40, class: 'form-control' %>
</div>
</div>

<div class="form-group">
<div class="col-md-10">
<%= f.label :email%>
<%= f.email_field :email, size: 40, class: 'form-control' %>
</div>
</div>

<div class="form-group">
<div class="col-md-10">
<%= f.label :address %>
<%= f.text_area :address, cols: 40, class: 'form-control' %>
</div>
</div>

<div class="form-group">
<div class="col-md-10">
<%= f.label :city %>
<%= f.text_field :city, size: 40, class: 'form-control' %>
</div>
</div>

<div class="form-group">
<div class="col-md-5">
<%= f.label :country %>
<%= f.country_select :country, { priority_countries: [ "IS", "US", "DE", "ES", "PT" ]}, { class: "form-control" }%>
</div>


</div>


<div class="form-group">

<div id="payment-form"></div>

<div class="col-md-10">
<br>
<%= f.submit 'Place Order', class: 'buttons' %>

</div>
</div>

</div>




here is the order part of the `schema.rb``

create_table "orders", force: :cascade do |t|
t.string "name"
t.string "email"
t.text "address"
t.string "city"
t.string "country"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "shipped", default: false
t.string "pick_up"
t.string "send"
end

Answer

I fear send is not a lucky name for an identifier because the send method.

http://ruby-doc.org/core-2.3.1/Object.html#method-i-send