ActionController::RoutingError Rails 和 Angular
ActionController::RoutingError Rails and Angular
每次调用 ProductController 时,Restangular 从 rails 服务器获取数据。我收到这个错误
ActionController::RoutingError (No route matches [GET] "/products.json/6862"):
我想如果product.json/:id 是带有rails 的路由它会自动去show view (show.json.jbuilder)。知道我错过了什么吗?
ProductController.js.coffee
controllers = angular.module('controllers')
controllers.controller("ProductController", [ '$scope', '$routeParams', '$location','Restangular'
($scope,$routeParams,$location,Restangular)->
Restangular.one('products.json', 6862).get().then (c) ->
console.log c
$scope.content = c
return
])
routes.rb
TindaIo::Application.routes.draw do
devise_for :users
root 'home#index'
resources :products, only: [:index, :show]
end
show.json.jbuilder
json.product do
json.title @product.title
end
我已经通过将 show.json.jbuilder 重命名为 show.jbuilder 解决了这个问题,只需使用 Restangular.one('products', 6862).get().then (c) - > ...
每次调用 ProductController 时,Restangular 从 rails 服务器获取数据。我收到这个错误
ActionController::RoutingError (No route matches [GET] "/products.json/6862"):
我想如果product.json/:id 是带有rails 的路由它会自动去show view (show.json.jbuilder)。知道我错过了什么吗?
ProductController.js.coffee
controllers = angular.module('controllers')
controllers.controller("ProductController", [ '$scope', '$routeParams', '$location','Restangular'
($scope,$routeParams,$location,Restangular)->
Restangular.one('products.json', 6862).get().then (c) ->
console.log c
$scope.content = c
return
])
routes.rb
TindaIo::Application.routes.draw do
devise_for :users
root 'home#index'
resources :products, only: [:index, :show]
end
show.json.jbuilder
json.product do
json.title @product.title
end
我已经通过将 show.json.jbuilder 重命名为 show.jbuilder 解决了这个问题,只需使用 Restangular.one('products', 6862).get().then (c) - > ...