Keep getting ActionController:UnknownFormat error when trying to use respond_to and respond_with in rails controller. Error on the following line in controller.
respond_with @surveys
In /app/assets/controllers/surveys_controller
respond_to :json
def index
@surveys = Survey.all
respond_with @surveys
end
In /config/routes.rb
WebInsight::Application.routes.draw do
scope :api do
resources :surveys, defaults: {format: 'json'}
end
resources :surveys
end
In /app/assets/views/surveys/index.html.erb
<h1>Your Surveys</h1>
<form>
<input type="text" ng-model='newSurvey' placeholder="Enter a survey">
<input type="submit" value="Add">
</form>
<div ng-controller="SurveysCtrl">
<ul>
<li ng-repeat="survey in surveys">
{{ survey.theme_id }}, {{ survey.name }}, {{ survey.description }}
</li>
</ul>
</div>
In /app/assets/javascripts/angular/controllers/surveys_ctrl.js
app.controller('SurveysCtrl', ['$scope', '$resource', function($scope, $resource) {
var Surveys = $resource('/api/surveys');
$scope.surveys = Surveys.query();
}]);