I’m trying to use Angularjs to get JSON from a Rails test app that I put on Heroku. Below you will find my Angular and Rails code.
This is the error that I get in my Firebug console. "NetworkError: 404 Not Found - http://desolate-earth-2852.herokuapp.com/declarations.json"
Is there a reason this is not working?
Angularjs code
var App = angular.module('App', []);
App.controller('TodoCtrl', function($scope, $http) {
$http.get('http://desolate-earth-2852.herokuapp.com/declarations.json')
.then(function(res){
$scope.todos = res.data;
});
});
Rails code
def index
@declarations = Declaration.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @declarations }
end
end
Here are the routes
Test::Application.routes.draw do
root :to => 'welcome#index'
get "welcome/index"
resources :declarations
end
resources :declarations
? – Edgars Jekabsons Oct 16 '13 at 21:31