I am using rails 4 and angularjs. I am follow railscast(http://railscasts.com/episodes/405-angularjs) tutorial. The tutorial on rails 3. The problem is that I am getting an error when I am trying to query data from database. Here is the error "GET localhost:3000/entries 406 (Not Acceptable)". I thing my angular code is working perfectly and may be the problem is in my controller. Because when I am using "localhost:3000/entries" link, I am getting this error "ActionController::UnknownFormat in EntriesController#index".
Controller:
class EntriesController < ApplicationController
respond_to :html, :json
def index
respond_with Entry.all
end
end
angular:
app = angular.module("Raffler", ["ngResource"])
app.factory "Entry", ["$resource", ($resource) ->
$resource("/entries/:id", {id: "@id"}, {update: {method: "PUT"}})
]
@RaffleCtrl = ["$scope", "Entry", ($scope, Entry) ->
$scope.entries = Entry.query()
]
view:
<div ng-controller="RaffleCtrl">
<form ng-submit="addEntry()">
<input type="text" ng-model="newEntry.name">
<input type="submit" value="Add">
</form>
<ul>
<li ng-repeat="entry in entries">
{{entry.name}}
<span ng-show="entry.winner" ng-class="{highlight: entry == lastWinner}" class="winner">WINNER</span>
</li>
</ul>
<button ng-click="drawWinner()">Draw Winner</button>
</div>