Class: LesliLetter::NotesController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /notes



69
70
71
72
73
74
75
76
77
# File 'app/controllers/lesli_letter/notes_controller.rb', line 69

def create
@note = Note.new(note_params)

if @note.save
redirect_to @note, notice: "Note was successfully created."
else
render :new, status: :unprocessable_entity
end
end

#destroyObject

DELETE /notes/1



92
93
94
95
# File 'app/controllers/lesli_letter/notes_controller.rb', line 92

def destroy
@note.destroy
redirect_to notes_url, notice: "Note was successfully destroyed.", status: :see_other
end

#editObject

GET /notes/1/edit



65
66
# File 'app/controllers/lesli_letter/notes_controller.rb', line 65

def edit
end

#indexObject

GET /notes



38
39
40
41
42
43
44
45
# File 'app/controllers/lesli_letter/notes_controller.rb', line 38

def index
    respond_to do |format|
        format.html {}
        format.json {
            respond_with_pagination(NoteService.new(current_user, query).index())
        }
    end
end

#newObject

GET /notes/new



60
61
62
# File 'app/controllers/lesli_letter/notes_controller.rb', line 60

def new
@note = Note.new
end

#showObject

GET /notes/1



48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/lesli_letter/notes_controller.rb', line 48

def show
    respond_to do |format|
        format.html {}
        format.json {
            pp "--------"
            respond_with_successful(@note.show())
            pp "--------"
        }
    end
end

#updateObject

PATCH/PUT /notes/1



80
81
82
83
84
85
86
87
88
89
# File 'app/controllers/lesli_letter/notes_controller.rb', line 80

def update

    @note.update(note_params)

    if @note.successful?
        return respond_with_successful(@note)
    end

    respond_with_error(@note.errors)
end