X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/443080d7b05b5e2cc3310699f5e9d5edde010aca..44b08cc35d5b5488919059016a427feae62acb05:/app/controllers/diary_entry_controller.rb diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index 454912b0e..07980adc8 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -81,21 +81,27 @@ class DiaryEntryController < ApplicationController end def subscribe - @entry = DiaryEntry.find(params[:id]) + diary_entry = DiaryEntry.find(params[:id]) if ! diary_entry.subscribers.exists?(@user.id) diary_entry.subscribers << @user + end redirect_to :controller => "diary_entry", :action => "view", :display_name => diary_entry.user.display_name, :id => diary_entry.id + rescue ActiveRecord::RecordNotFound + render :action => "no_such_entry", :status => :not_found end def unsubscribe - @entry = DiaryEntry.find(params[:id]) + diary_entry = DiaryEntry.find(params[:id]) if diary_entry.subscribers.exists?(@user.id) diary_entry.subscribers.delete(@user) + end redirect_to :controller => "diary_entry", :action => "view", :display_name => diary_entry.user.display_name, :id => diary_entry.id + rescue ActiveRecord::RecordNotFound + render :action => "no_such_entry", :status => :not_found end def list