2011-06-13 22:39:39 +00:00
|
|
|
class RemindersController < ApplicationController
|
|
|
|
respond_to :json
|
|
|
|
|
|
|
|
def create
|
2012-11-15 17:34:19 +00:00
|
|
|
@reminder = Reminder.new(reminder_params)
|
2012-06-18 17:49:28 +00:00
|
|
|
@reminder.from_user = current_user
|
2011-06-13 22:39:39 +00:00
|
|
|
if @reminder.save
|
2011-10-10 21:10:01 +00:00
|
|
|
ThingMailer.reminder(@reminder.thing).deliver
|
2011-06-25 09:38:00 +00:00
|
|
|
@reminder.update_attribute(:sent, true)
|
2014-03-25 09:47:44 +00:00
|
|
|
render(json: @reminder)
|
2011-06-13 22:39:39 +00:00
|
|
|
else
|
2014-03-25 09:47:44 +00:00
|
|
|
render(json: {errors: @reminder.errors}, status: 500)
|
2011-06-13 22:39:39 +00:00
|
|
|
end
|
|
|
|
end
|
2012-11-15 17:34:19 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def reminder_params
|
|
|
|
params.require(:reminder).permit(:thing_id, :to_user_id)
|
|
|
|
end
|
2011-06-13 22:39:39 +00:00
|
|
|
end
|