Every time ProductController is called and Restangular getting data from the rails server. I got this error
ActionController::RoutingError (No route matches [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). Any idea what did I miss?
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
I have solve this problem by renaming show.json.jbuilder to show.jbuilder and just use Restangular.one('products', 6862).get().then (c) -> ...