Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4bdcb02da4
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (33 sloc) 1.142 kb
String::dasherize = ->
this.replace /_/g, "-"
String::senitize = ->
this.replace /_/g, "-"
#alert "one_two".dasherize()
class RailsBackboneRelational.Models.Post extends Backbone.RelationalModel
paramRoot: 'post'
defaults:
title: 'title?'
relations: [
type: Backbone.HasMany
key: 'comments'
relatedModel: 'RailsBackboneRelational.Models.Comment'
collectionType: 'RailsBackboneRelational.Collections.CommentsCollection'
includeInJSON: false
reverseRelation:
key: 'post_id',
includeInJSON: 'id'
]
validate: (attrs) ->
if (attrs.hasOwnProperty('title') && _.isNull(attrs.title))
return 'attr.direction must be a non null value.'
sanitize1: (str) ->
str.senitize()
initialize: () ->
console.log('init post')
class RailsBackboneRelational.Collections.PostsCollection extends Backbone.Collection
model: RailsBackboneRelational.Models.Post
url: '/posts'
initialize: () ->
#console.log('init post')
#alert('new collection posts')
#localStorage: new Backbone.LocalStorage("PostsCollection")
Jump to Line
Something went wrong with that request. Please try again.