diff options
Diffstat (limited to 'app/controllers/alerts_controller.rb')
-rw-r--r-- | app/controllers/alerts_controller.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/controllers/alerts_controller.rb b/app/controllers/alerts_controller.rb index a3cb8f9..6ab3663 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,7 +23,7 @@ class AlertsController < ApplicationController # POST /alerts.json def create @alert = Alert.new(alert_params) - + @alert.author = current_user respond_to do |format| if @alert.save format.html { redirect_to @alert, notice: 'Alert was successfully created.' } @@ -62,11 +60,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) |