I have a collection and a Backbone.js model for a project object:
window.Project = Backbone.Model.extend(); window.Projects = Backbone.Collection.extend({ model: Project, url: '/projects' });
I installed a rail controller to respond to the Backbone.js collection:
class ProjectsController < ApplicationController def index render :json => Project.all end def create project = Project.create! params render :json => project end end
The index works fine and I get a list of projects in my web application. The problem is that if I try to create a model in the project collection, I get a 500 error from the server.
The error message on the server is as follows:
Started POST "/projects" for 127.0.0.1 at 2011-08-21 08:27:56 +0100 Processing by ProjectsController#create as JSON Parameters: {"title"=>"another test"} Completed 500 Internal Server Error in 16ms ActiveRecord::UnknownAttributeError (unknown attribute: action): app/controllers/projects_controller.rb:8:in `create'
I'm not sure what unknown attribute: action means.
For information, I set projects_controller as resources :projects . I also set the rails to ActiveRecord::Base.include_root_in_json = false .
source share