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

22 lines
508 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(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
ThingMailer.reminder(@reminder.thing).deliver_now
@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
private
def reminder_params
params.require(:reminder).permit(:thing_id, :to_user_id)
end
2011-06-13 22:39:39 +00:00
end