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

22 lines
516 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
2011-10-10 21:10:01 +00:00
ThingMailer.reminder(@reminder.thing).deliver
@reminder.update_attribute(:sent, true)
render(:json => @reminder)
2011-06-13 22:39:39 +00:00
else
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