Я создаю заказ API в рельсах 4. Когда я создаю заказ в своем действии на создание, я не мог понять эту ошибку ниже.отсутствует или значение пуст:
Started POST "/api/v1/orders?access_token=testing" for 127.0.0.1 at 2015-06-22 12:23:55 +0530
Processing by Api::V1::OrdersController#create as JSON
Parameters: {"access_token"=>"testing"}
ApiKey Load (1.0ms) SELECT `api_keys`.* FROM `api_keys` WHERE `api_keys`.`access_token` = 'testing' LIMIT 1
Restaurant Load (0.3ms) SELECT `restaurants`.* FROM `restaurants` WHERE `restaurants`.`id` IS NULL LIMIT 1
ActionController::ParameterMissing - param is missing or the value is empty: order:
Мой код контроллера:
Orders_controller.rb
class Api::V1::OrdersController < Api::V1::ApplicationController
protect_from_forgery with: :null_session
skip_before_filter :verify_authenticity_token, :if => Proc.new {|c| c.request.format.json? }
before_action :fetch_restaurent
before_action :fetch_food_items, :only => [:index]
after_action :send_order_to_kitchen, :only => [:create, :update]
def app_sync
end
def index
@orders = Restaurant.orders.fetch_items_from_ethor
end
def show
# Display the list of food_items available from the restaurant
# Allow the customer to place an order
end
def create
@order = Order.build(order_params)
if @order.save
render :json, order, status:201, location: [:api, current_customer, order]
else
render :json, { errors: order.errors }, status:422
end
end
# once the order is placed just send it to the kitechn()
def update
@order = Order.find_by(params[:id])
@rder.update_attributes(order_params)
if @order.save
render :json, order, status: 201, location: [:api, current_user.order.id]
else
render :json,{errors: order.errors}, status: 422
end
end
private
def order_params
params.require(:order).permit(:customer_id, :order_id, :pos_id, :table_id, :order_number,
:order_status,:order_date, :subtotal, :final_total, :order_type, :food_item_ids => [])
end
end
Я не уверен, что я делаю неправильно. Пожалуйста, помогите мне.
Как вы делаете запрос на создание «заказа»? –
G.B. Я тестирую это, используя почтальон. – user5035102
Вы также можете добавить снимок экрана этого запроса? –