X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/e7ddfe10846f89b5eeec4bf4f4dc03057a744009..ee4c34172f0a0145344525962cc5411a7f260ff5:/app/controllers/diary_entries_controller.rb diff --git a/app/controllers/diary_entries_controller.rb b/app/controllers/diary_entries_controller.rb index 1f9574b9c..1a3d648f4 100644 --- a/app/controllers/diary_entries_controller.rb +++ b/app/controllers/diary_entries_controller.rb @@ -157,21 +157,25 @@ class DiaryEntriesController < ApplicationController end def subscribe - diary_entry = DiaryEntry.find(params[:id]) + @diary_entry = DiaryEntry.find(params[:id]) - diary_entry.subscriptions.create(:user => current_user) unless diary_entry.subscribers.exists?(current_user.id) + if request.post? + @diary_entry.subscriptions.create(:user => current_user) unless @diary_entry.subscribers.exists?(current_user.id) - redirect_to diary_entry_path(diary_entry.user, diary_entry) + redirect_to diary_entry_path(@diary_entry.user, @diary_entry) + end rescue ActiveRecord::RecordNotFound render :action => "no_such_entry", :status => :not_found end def unsubscribe - diary_entry = DiaryEntry.find(params[:id]) + @diary_entry = DiaryEntry.find(params[:id]) - diary_entry.subscriptions.where(:user => current_user).delete_all if diary_entry.subscribers.exists?(current_user.id) + if request.post? + @diary_entry.subscriptions.where(:user => current_user).delete_all if @diary_entry.subscribers.exists?(current_user.id) - redirect_to diary_entry_path(diary_entry.user, diary_entry) + redirect_to diary_entry_path(@diary_entry.user, @diary_entry) + end rescue ActiveRecord::RecordNotFound render :action => "no_such_entry", :status => :not_found end