adopt-a-hydrant/app/controllers/reminders_controller.rb

16 lines
407 B
Ruby
Raw Normal View History

2011-06-13 22:39:39 +00:00
class RemindersController < ApplicationController
respond_to :json
def create
@reminder = Reminder.new(params[:reminder])
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
@reminder.update_attribute(:sent, true)
2012-06-18 17:49:28 +00:00
render(json: @reminder)
2011-06-13 22:39:39 +00:00
else
2012-06-18 17:49:28 +00:00
render(json: {errors: @reminder.errors}, status: 500)
2011-06-13 22:39:39 +00:00
end
end
end