Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4bdcb02da4
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 51 lines (33 sloc) 1.142 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

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")
Something went wrong with that request. Please try again.