无法从 Rails API 获取 JSON 数据

Can't get JSON data from Rails API

我向 http://localhost:3000/cars/1 发出获取请求,但服务器未回复 json 数据。是这样说的

Started GET "/api/cars/1" for 127.0.0.1 at 2016-10-07 12:47:34 +0600
Processing by Api::V1::CarsController#show as HTML
Parameters: {"id"=>"1"}
User Load (0.5ms)  SELECT  "users".* FROM "users" WHERE "users"."uid"       =  LIMIT   [["uid", "sahidul03@gmail.com"], ["LIMIT", 1]]
Car Load (0.6ms)  SELECT  "cars".* FROM "cars" WHERE "cars"."id" =     LIMIT   [["id", 1], ["LIMIT", 1]]
User Load (1.0ms)  SELECT  "users".* FROM "users" WHERE "users"."id" =  LIMIT   [["id", 1], ["LIMIT", 1]]
Started GET "/" for 127.0.0.1 at 2016-10-07 12:47:34 +0600
Processing by Rails::WelcomeController#index as HTML
Parameters: {"internal"=>true}
(2.9ms)  BEGIN
Rendering /home/sahidul/.rvm/gems/ruby-2.2.3/gems/railties- 5.0.0.1/lib/rails/templates/rails/welcome/index.html.erb
Rendered /home/sahidul/.rvm/gems/ruby-2.2.3/gems/railties-5.0.0.1/lib/rails/templates/rails/welcome/index.html.erb (3.9ms)
Completed 200 OK in 11ms (Views: 10.2ms | ActiveRecord: 0.0ms)


(6.8ms)  COMMIT
Completed 200 OK in 25ms (Views: 1.3ms | ActiveRecord: 11.8ms)

我的控制器方法就是这样

 def show
   car= Car.find(params[:id])
   render json: car
 end

前端请求为

  function getCar(id) {
        return $http.get($auth.domain + '/api/cars/' + id);
    }

我在后端使用 devise_token_auth gem,在前端使用 ng-token-auth

.json 附加到 URL

$http.get($auth.domain + '/api/cars/' + id + '.json');

希望对您有所帮助!