Created
May 14, 2011 06:36
-
-
Save rubiety/971993 to your computer and use it in GitHub Desktop.
Jazzity Rails + Backbone.js + Coffeescript Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Scale < ActiveRecord::Base | |
include KeyContext | |
has_many :tones, :class_name => 'ScaleTone', :extend => ToneSequence, :dependent => :destroy | |
delegate :notes, :to => :tones | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ScalesController < ApplicationController | |
respond_to :html, :json | |
def index | |
@scales = Scale.active | |
respond_with @scales | |
end | |
def show | |
@scale = Scale.find(params[:id]) | |
respond_with @scale | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jazzity.Scale = Backbone.Model.extend url: -> "/scales/" + this.id | |
major = new Jazzity.Scale id: "major" | |
major.fetch # HTTP GET /scales/major.json | |
# major.attributes => | |
# { | |
# name: "The Major Scale", | |
# notes: ["C", "D", "E", "F", "G", "A", "B"], | |
# symmetric: false | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment