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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:11:56+00:00 2026-05-28T04:11:56+00:00

I am trying to get a CoffeeScript class to extend a Backbone.Model. I built

  • 0

I am trying to get a CoffeeScript class to extend a Backbone.Model. I built a brand new rails 3.1 app, created a scaffold of ‘Stone’, with 3 attributes, and patched a snippet of the Todos.coffee example into stones.js.coffee. I have both backbone.js and underscore.js in the app/assets/javascripts folder. When I run this under the Chrome Java console, I get the message above in the console log. Any ideas?

Actual code follows:

$ -> 

  class Todo extends Backbone.Model
    # Default attributes for the todo.
    defaults:
     content: "empty todo..."
     done: false

    # Ensure that each todo created has `content`.
    initialize: ->
      if !@get("content")
      @set({ "content": @defaults.content })

    # Toggle the `done` state of this todo item.
    toggle: ->
      @save({ done: !@get("done") })

    # Remove this Todo from *localStorage* and delete its view.
    clear: ->
      @destroy()
      @view.remove()

The application.js being used is what was generated by Rails 3.1. I copied the backbone.js and underscore.js from the Todos github repo, https://github.com/JasonGiedymin/backbone-todojs-coffeescript

  • 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-28T04:11:56+00:00Added an answer on May 28, 2026 at 4:11 am

    The problem is simply that underscore.js is being loaded after backbone.js, when it’s a prereq that has to be loaded before. (Notice in the Backbone.js source that it sets var _ = root._ immediately, so even if a global _ is declared later, it’s not visible from Backbone’s scope.) Sprockets loads the JS files in your assets directory in alphabetical order by default.

    You can fix this using Sprockets: Put

    //= require underscore.js
    

    before

    //= require_tree .
    

    to ensure that it’s loaded first.

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

Sidebar

Related Questions

I'm trying to get Jasmine (jasmine-headless-webkit), coffeescript and backbone to work together. I'm close
I am new to CoffeeScript and am trying to get a feel for the
I'm trying to upload a Rails 3.1 app (with CoffeeScript) to Heroku. Apparently, there
I'm trying to use CoffeeScript with Backbone.js (via Brunch) and I want to implement
Ladies & Gentlemen, Short Version: Trying to dynamically create a Spine Model Class. Basically
I am quite new to vim and I am trying to edit coffeescript. Whenever
I'm trying to get the nodeunit module working within a coffeescript project but can't
Ok, I just bought the new 27 inch iMac and I am trying get
Trying to understand how CoffeeScript instance and class variable works I came with this
As a pet project, I am trying to get familiar with NodeJS and CoffeeScript,

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.