Skip to content

Instantly share code, notes, and snippets.

@pilt
Created July 3, 2011 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pilt/1062202 to your computer and use it in GitHub Desktop.
Save pilt/1062202 to your computer and use it in GitHub Desktop.
Getting "Uncaught TypeError: Object #<Object> has no method 'products'"
# The browser client.
now = window.now
Page = Backbone.Model.extend {}
Pages = Backbone.Collection.extend
mode: Page
window.pages = new Pages
Sidebar = Backbone.Model.extend {
loadPage: (page) ->
@set page: page
}
Product = Backbone.Model.extend {}
Products = Backbone.Collection.extend
mode: Product
window.products = new Products
Workspace = Backbone.Router.extend
routes:
"products": "products",
"product/:id": "product"
products: () ->
"moo"
product: (id) ->
"moo"
window.workspace = new Workspace()
Backbone.sync = (method, model, opts) ->
console.log method, model. opts
Backbone.history.start pushState: true
now.ready ->
console.log "now is ready"
now.products (prods) ->
products.add(prods)
nowjs = require "now"
express = require "express"
path = require "path"
products = require './products'
settings = require './config/settings'
app = express.createServer()
app.register '.coffee', require('coffeekup')
app.set 'view engine', 'coffee'
app.use express.logger()
app.use express.bodyParser()
app.configure 'development', () ->
projDir = path.join __dirname, '..'
staticDir = path.join(projDir, 'static')
viewsDir = path.join(projDir, 'views')
app.set 'views', viewsDir
app.use(express.static(staticDir))
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }))
console.log "configured for development"
everyone = nowjs.initialize(app)
everyone.now.products = (cb) ->
products.all cb
home = (req, res) ->
res.render 'home'
app.get '/', home
paid = (req, res) ->
res.render 'paid'
app.get '/paid', paid
addProduct = (req, res) ->
res.render 'addProduct'
app.get '/products/add', addProduct
addedProduct = (req, res) ->
products.add req.body.name, req.body.price
listProducts req, res
app.post '/products/added', addedProduct
listProducts = (req, res) ->
products.all (prods) ->
res.render 'listProducts', locals: {products: prods}
app.get '/products/list', listProducts
app.listen(settings.nodePort)
@pilt
Copy link
Author

pilt commented Jul 3, 2011

Adding --bare (no top-level function wrapper) to coffee command solves it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment