Class: NotesController

Inherits:
ApplicationController show all
Defined in:
lib/scaffold/app/controllers/notes_controller.rb

Constant Summary

Constants included from ControllerCallbacks

ControllerCallbacks::METHODS

Instance Attribute Summary

Attributes inherited from ControllerBase

#params, #req, #res

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #ensure_login, #ensure_logout, #logged_in?, #login, #logout

Methods inherited from ControllerBase

#form_authenticity_token, #initialize, #invoke_action, #link_to, protect_from_forgery, #root_url

Methods included from ControllerCallbacks

#before_action

Constructor Details

This class inherits a constructor from ControllerBase

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
# File 'lib/scaffold/app/controllers/notes_controller.rb', line 4

def create
  note = Note.new(note_params)
  note.user_id = current_user.id
  note.save
  flash[:errors] = note.errors
  
  redirect_to track_url(note.track_id)
end

#destroyObject



13
14
15
16
17
# File 'lib/scaffold/app/controllers/notes_controller.rb', line 13

def destroy
  note = Note.find(params[:id])
  note.destroy
  redirect_to track_url(note.track_id)
end