I tried different ways to retrieve json-data unsuccessfully
my order.js.coffee
$.ajax(
url: "/orders/", // want "/orders/1"
dataType: "JSON"
).done (data) ->
console.log data.status
my controller:
class OrdersController < ApplicationController
respond_to :json, :js, :html
def show
@order = Order.find(params[:id])
respond_with @order
end
....
my show.json.jbuilder
json.extract! @order, :id, :status
and here my route:
get '/orders/:id', to: 'orders#show', defaults: {format: :json}
resources :orders, only: [:new, :create]
...
I got a lot of errors with different approach.
Started GET "/orders/" for 127.0.0.1 at 2014-10-07 01:07:36 +0200
ActionController::RoutingError (No route matches [GET] "/orders"):
or
ERROR bad URI `/orders/%3C%=%20order.id%20%%3E'