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 7525131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:27:13+00:00 2026-05-30T03:27:13+00:00

Can someone help me understand how to make Ryan Bate’s screencast on Backbone.js work

  • 0

Can someone help me understand how to make Ryan Bate’s screencast on Backbone.js work with MongoDB as my database while using the Mongoid gem.

This is what I am seeing.

When I create a new entry via the console, similar to how Ryan did it in the video with entry.create, Rails adds that entry just fine. Below is my Ruby log and my JavaScript headers log from Chrome Inspector.

Ruby Log

Started POST "/api/entries" for 127.0.0.1 at 2012-02-12 17:31:24 -0600
Processing by EntriesController#create as JSON
Parameters: {"name"=>"Heather", "entry"=>{"name"=>"Heather", "action"=>"create",         "controller"=>"entries"}}
MONGODB w_market_development['system.namespaces'].find({})
MONGODB           w_market_development['entries'].insert([{"_id"=>BSON::ObjectId('4f384bcc504b9348be000003'),     "name"=>"Heather"}])
Completed 201 Created in 11ms (Views: 2.4ms)

Headers Log

Request URL:http://0.0.0.0:3000/api/entries
Request Method:POST
Status Code:201 Created
Request Headers (14)
Request Payload
{"name":"Heather"}

As you can see it posted fine. Now let me show you an update via the entry.save() example Ryan showed us.

Ruby Log

Started POST "/api/entries" for 127.0.0.1 at 2012-02-12 17:34:25 -0600
Processing by EntriesController#create as JSON
Parameters: {"_id"=>"4f38152c504b9345dc000005", "name"=>"Bloip", "winner"=>true,     "entry"=>{"_id"=>"4f38152c504b9345dc000005", "name"=>"Bloip", "winner"=>true,     "action"=>"create", "controller"=>"entries"}}
MONGODB w_market_development['system.namespaces'].find({})
MONGODB     w_market_development['entries'].insert([{"_id"=>BSON::ObjectId('4f38152c504b9345dc000005'),     "name"=>"Bloip", "winner"=>true}])
Completed 201 Created in 12ms (Views: 2.7ms)

Headers Log

Request URL:http://0.0.0.0:3000/api/entries
Request Method:POST
Status Code:201 Created
Request Headers (14)
Request Payload
{"_id":"4f38152c504b9345dc000005","name":"Bloip","winner":true}

As you can see when I complete the entry.save() on a current entry, which should be an update, the JSON is showing a POST instead of a PUT, which Mongoid is doing nothing with and the DB shows no changes. After Googling I found the following articles but nothing really helped.

https://github.com/codebrew/backbone-rails/issues/8
http://lostechies.com/derickbailey/2011/06/17/making-mongoid-play-nice-with-backbone-js/

  • 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-30T03:27:15+00:00Added an answer on May 30, 2026 at 3:27 am

    When I was going through the RailsCast as described above. I was using the entries controller that Ryan put together. After much searching, copying, pasting, and retrying I found that I need a completely new Controller set up. Below is what I originally had.

    class EntriesController < ApplicationController
      respond_to :json
    
      def index
        respond_with Entry.all
      end
    
      def show
        respond_with Entry.find(params[:id])
      end
    
      def create
        respond_with Entry.create(params[:entry])
      end
    
      def update
        respond_with Entry.update(params[:id], params[:entry])
      end
    
      def destroy
        respond_with Entry.destroy(params[:id])
      end
    end
    

    This is the Controller code the fixed the issue for me.

    class EntriesController < ApplicationController
      def index
          render :json => Entry.all
        end
    
        def show
          render :json => Entry.find(params[:id])
        end
    
        def create
          entry = Entry.create! params
          render :json => entry
        end
    
        def update
          entry = Entry.find(params[:id])
          entry.update_attributes!(params[:entry])
          render :json => entry
        end
    
        def destroy
          render :json => Entry.destroy(params[:id])
        end
      end
    

    Thanks All!

    Travis

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

Sidebar

Related Questions

I'm hoping someone can help me understand a process of recycling a webservice using
Can someone help me figure out the following make file? BINS=file1 file2 file3 all:
Can someone please help me understand this solution : Initialize 2D array with 81
can someone help me. I've been reading about salting a password to make my
Can someone help me understand why the following query is not offsetting correctly? It's
Can someone help me identify what the purpose of this unidentified syntax is. It
Can someone help explain the following: If I type: a=`ls -l` Then the output
Can someone help me with the getopt function? When I do the following in
Can someone help me with this: This is a program to find all the
Can someone help me to find a solution on how to calculate a cubic

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.