我想列出一個帖子的內容使用Angular與Rails,但完全卡住。'顯示'與Angular和Rails的動作
我的控制器:
var myApp = angular.module('myApp', ['ngResource']);
myApp.controller('categoryController', ['$scope', 'Post',function($scope, Post) {
$scope.heading = "Hello from angular";
$scope.post = Post.query();
}])
myApp.factory('Post', ['$resource', function($resource) {
return $resource('/posts/:id', { id: "@id" });
}])
Rails的帖子控制器:
def show
@post = Post.find(params[:id])
respond_to do |format|
format.html
format.json { render json: @post }
end
end
'你好,從角' 是顯示了罰款,但剩下的給我一個錯誤:
GET http://localhost:3000/posts/show 500 (Internal Server Error)
找不到找出這個壞男孩的正確方法。 謝謝你的任何有用的輸入
編輯:routes.rb中
resources :users
resources :hubs, shallow: true do
resources :posts, shallow: true
resources :comments, shallow: true do
collection {post :sort}
end
end
你可以張貼'routes.rb'的內容是什麼? – zeantsoi
@zeantsoi肯定的事情!更新 –