[英]ActionController::RoutingError Rails and Angular
Every time ProductController is called and Restangular getting data from the rails server. 每次调用ProductController时,Restangular会从Rails服务器获取数据。 I got this error
我得到这个错误
ActionController::RoutingError (No route matches [GET] "/products.json/6862"):
ActionController :: RoutingError(没有路由与[GET]“ / products.json / 6862”匹配):
I thought if product.json/:id is the route with rails it will automatically go to show view (show.json.jbuilder). 我以为如果product.json /:id是带有rails的路由,它将自动进入显示视图(show.json.jbuilder)。 Any idea what did I miss?
知道我想念什么吗?
ProductController.js.coffee 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 routes.rb
TindaIo::Application.routes.draw do
devise_for :users
root 'home#index'
resources :products, only: [:index, :show]
end
show.json.jbuilder show.json.jbuilder
json.product do
json.title @product.title
end
我已经通过将show.json.jbuilder重命名为show.jbuilder并使用Restangular.one('products',6862).get()。then(c)-> ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.