diff options
Diffstat (limited to 'app/controllers/alerts_controller.rb')
-rw-r--r-- | app/controllers/alerts_controller.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/controllers/alerts_controller.rb b/app/controllers/alerts_controller.rb index a3cb8f9..77ca8b9 100644 --- a/app/controllers/alerts_controller.rb +++ b/app/controllers/alerts_controller.rb @@ -1,6 +1,4 @@ class AlertsController < ApplicationController - before_action :set_alert, only: [:show, :edit, :update, :destroy] - # GET /alerts # GET /alerts.json def index @@ -25,6 +23,14 @@ class AlertsController < ApplicationController # POST /alerts.json def create @alert = Alert.new(alert_params) + @alert.author = current_user + users = {} + users = User.all + + + for i in 0..users.length + current_user.send_message(users[i], @alert.message, "Pay Attention!") + end respond_to do |format| if @alert.save @@ -62,11 +68,16 @@ class AlertsController < ApplicationController end private + # Use callbacks to share common setup or constraints between actions. def set_alert @alert = Alert.find(params[:id]) end + def is_owner?(object) + object.author == current_user + end + # Never trust parameters from the scary internet, only allow the white list through. def alert_params params.require(:alert).permit(:author_id, :message) |