Skip to content

Instantly share code, notes, and snippets.

@JKring
Created October 5, 2013 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JKring/6845841 to your computer and use it in GitHub Desktop.
Save JKring/6845841 to your computer and use it in GitHub Desktop.
async photo uploading
def upload_photo
event = Event.find(params[:event_id])
params.delete(:event_id)
icon = EventIcon.create(params)
# This requires setting up a many-to-one relationship between icons and events
event.icons << icon
event.save!
render json: {
id: icon.id,
name: icon.photo_file_name,
url: icon.photo.url
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment