mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-22 02:00:12 +01:00
change notes controller to enable adding notes through REST api.
see http://www.getontracks.org/forums/viewthread/530/
This commit is contained in:
parent
226d902127
commit
c9566047fc
2 changed files with 25 additions and 9 deletions
|
|
@ -27,13 +27,29 @@ class NotesController < ApplicationController
|
|||
|
||||
def create
|
||||
note = current_user.notes.build
|
||||
note.attributes = params["new_note"]
|
||||
|
||||
if note.save
|
||||
render :partial => 'notes_summary', :object => note
|
||||
else
|
||||
render :text => ''
|
||||
end
|
||||
note.attributes = params["note"]
|
||||
|
||||
saved = note.save
|
||||
|
||||
respond_to do |format|
|
||||
format.js do
|
||||
if note.save
|
||||
render :partial => 'notes_summary', :object => note
|
||||
else
|
||||
render :text => ''
|
||||
end
|
||||
end
|
||||
format.xml do
|
||||
if saved
|
||||
head :created, :location => note_url(note), :text => "new note with id #{note.id}"
|
||||
else
|
||||
render_failure note.errors.full_messages.join(', ')
|
||||
end
|
||||
end
|
||||
format.html do
|
||||
render :text => 'unexpected request for html rendering'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue