diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 78e5316..414c282 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -50,10 +50,19 @@ def update # DELETE /photos/1 or /photos/1.json def destroy - @photo.destroy - respond_to do |format| - format.html { redirect_back fallback_location: root_url, notice: "Photo was successfully destroyed." } - format.json { head :no_content } + if @photo.owner_id = current_user.id + puts "positive id check, photo destroyed" + @photo.destroy + respond_to do |format| + format.html { redirect_back fallback_location: root_url, notice: "Photo was successfully destroyed." } + format.json { head :no_content } + end + else + puts "negative id check, redirected" + respond_to do |format| + format.html { redirect_back fallback_location: root_url, notice: "Photo was successfully destroyed." } + format.json { head :no_content } + end end end diff --git a/app/views/photos/_photo.html.erb b/app/views/photos/_photo.html.erb index c40f7f7..02b0aff 100644 --- a/app/views/photos/_photo.html.erb +++ b/app/views/photos/_photo.html.erb @@ -7,12 +7,14 @@