Class: OutroRails::ChordCharts::VoicingsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- OutroRails::ChordCharts::VoicingsController
- Defined in:
- app/controllers/outro_rails/chord_charts/voicings_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/outro_rails/chord_charts/voicings_controller.rb', line 16 def create voicing = @chord.voicings.find(params.require(:chord_voicing_id)) selection = @chord_chart.voicings.find_or_initialize_by( chord: @chord, instrument: @instrument, bass: @bass.to_s ) selection.chord_voicing = voicing if selection.save redirect_to after_change_path, notice: "Now showing #{voicing.symbol} " \ "for #{@chord.symbol}." elsif return_to_path redirect_to return_to_path, alert: selection.errors..to_sentence else set_voicings flash.now[:alert] = selection.errors..to_sentence render :index, status: :unprocessable_entity end end |
#destroy ⇒ Object
37 38 39 40 41 42 |
# File 'app/controllers/outro_rails/chord_charts/voicings_controller.rb', line 37 def destroy @chord_chart.voicings.find(params[:id]).destroy redirect_to after_change_path, notice: "Reverted to the default voicing." end |
#index ⇒ Object
12 13 14 |
# File 'app/controllers/outro_rails/chord_charts/voicings_controller.rb', line 12 def index set_voicings end |