Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6347115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:08:52+00:00 2026-05-24T21:08:52+00:00

I have Backbone.js collection and model for a project object: window.Project = Backbone.Model.extend(); window.Projects

  • 0

I have Backbone.js collection and model for a project object:

window.Project = Backbone.Model.extend();

window.Projects = Backbone.Collection.extend({
    model: Project, 
    url: '/projects'
});

I have setup a rails 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

Index works fine and I get a list of projects in my web app. The problem is if I try and create a model on the Projects 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 am not sure what the unknown attribute: action is referring to.

For info I have set up the projects_controller as resources :projects. I have also set rails to ActiveRecord::Base.include_root_in_json = false.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:08:53+00:00Added an answer on May 24, 2026 at 9:08 pm

    Yes, Rails always adds the action and controller to params. The parameters come from ActionDispatch::Http::Parameters:

    def parameters
      @env["action_dispatch.request.parameters"] ||= begin
        params = request_parameters.merge(query_parameters)
        params.merge!(path_parameters)
        encode_params(params).with_indifferent_access
      end
    end
    

    And path_parameters:

    Returns a hash with the parameters used to form the path of the request. Returned hash keys are strings:

    {'action' => 'my_action', 'controller' => 'my_controller'}
    

    So you shouldn’t be doing project = Project.create! params. You could go the update_attributes route:

    project = Project.new
    project.update_attributes params[:model_name]
    

    But this assumes that you have what you need in a sub-hash of params and it won’t call your validators. Backbone won’t namespace your attributes by default but you could override Backbone.sync and do it yourself. Still, you probably want your validations so update_attributes should generally be avoided.

    Your best bet is to pull exactly the attributes out of params that you’re expecting to be there. This is even the Backbone recommended practise:

    *(In real code, never use update_attributes blindly, and always whitelist the attributes you allow to be changed.)*

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let's say I have : var Book = Backbone.Model.extend(); var Collection = Backbone.Collection.extend({ model:
I have the following Parent Object: Context = { ContextModel: Backbone.Model.extend({ //model Code }),
I have notifications in my Rails & Backbone.js app // MODEL NotificationModel = App.BB.Model.extend({
I'm using codebrew\backbone-rails in a nested model example (say I have a collection of
I have a super simple Backbone model/collection that wraps around a facebook feed. window.Story
I have the following backbone.js controller: App.Controllers.PlanMembers = Backbone.Controller.extend({ routes: { message/:messageType: sendMessage, :
I have a Backbone.js Collection and I have an array of model IDs that
I have a Backbone.Model named Company . My Company model has an Employees Backbone.Collection
I have the following: // MODEL NotificationModel = C.BB.Model.extend({ defaults : { read :
I've got a Backbone.Collection full of models; let's say that model is Car .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.