Class ChordsController
In: app/controllers/chords_controller.rb
Parent: ApplicationController

Chords REST API

Could be referenced in many RESTful contexts:

Methods

Public Instance methods

GET /chords GET /chords.xml GET /chords.js

[Source]

    # File app/controllers/chords_controller.rb, line 15
15:   def index
16:     respond_to do |format|
17:       format.html
18:       format.xml { render :xml => @chords.to_xml(:skip_types => true, :methods => [:symbols_list], :except => [:id, :parent_id, :chord_quality_id]) }
19:                         format.js { render :text => @chords.to_json(:except => [:id, :parent_id, :chord_quality_id]) }
20:     end
21:   end

GET /chords/maj7 GET /chords/maj7.xml GET /chords/maj7.js

[Source]

    # File app/controllers/chords_controller.rb, line 26
26:   def show
27:     respond_to do |format|
28:       format.html
29:       format.xml { render :xml => @chord.to_xml(:skip_types => true, :methods => [:symbols_list], :except => [:id, :chord_quality_id, :parent_id], :include => [:chord_quality, :parent]) }
30:                         format.js { render :text => @chord.to_json(:except => [:id, :chord_quality_id, :parent_id], :include => [:parent]) }
31:     end
32:   end

Protected Instance methods

[Source]

    # File app/controllers/chords_controller.rb, line 48
48:         def get_chord
49:                 get_relateds
50:                 @chord = case
51:                 when @mode then @mode.chords[params[:id]]
52:                 when @scale then @scale.chords[params[:id]]
53:                 when @chord_quality then @chord_quality.chords[params[:id]]
54:                 when @notes_collection then @notes_collection.chords[params[:id]]
55:                 else Chord[params[:id]]
56:                 end
57:         end

[Source]

    # File app/controllers/chords_controller.rb, line 37
37:         def get_chords
38:                 get_relateds
39:                 @chords = case 
40:                 when @mode then @mode.chords
41:           when @scale then @scale.chords
42:                 when @chord_quality then @chord_quality.chords
43:                 when @notes_collection then @notes_collection.chords
44:                 else Chord.find(:all, :include => [:symbols])
45:                 end
46:         end

[Source]

    # File app/controllers/chords_controller.rb, line 59
59:         def get_relateds
60:                 @scale = Scale[params[:scale_id]] if params[:scale_id]
61:                 @mode = @scale.modes[params[:mode_id]] if params[:mode_id] and @scale
62:                 @chord_quality = ChordQuality[params[:chord_quality_id]] if params[:chord_quality_id]
63:                 @notes_collection = NotesCollection[params[:notes_collection_id]] if params[:notes_collection_id]
64:         end

[Validate]