Merge pull request #288 from opf/feature/rails3_fix_attachment_errors

Removed the requirement of attachment containers having
pull/289/merge
Philipp Tessenow 11 years ago
commit 3c6f6cc42e
  1. 7
      app/controllers/attachments_controller.rb
  2. 3
      app/models/attachment.rb

@ -44,7 +44,12 @@ class AttachmentsController < ApplicationController
@attachment.container.attachments.delete(@attachment)
redirect_to :back
rescue ::ActionController::RedirectBackError
redirect_to :controller => '/projects', :action => 'show', :id => @project
# we cannot be sure the container actually has a project (example: LandingPage)
if @project
redirect_to :controller => '/projects', :action => 'show', :id => @project
else
redirect_to home_url
end
end
private

@ -144,7 +144,8 @@ class Attachment < ActiveRecord::Base
end
def project
container.project
#not every container has a project (example: LandingPage)
container.respond_to?(:project)? container.project : nil
end
def visible?(user=User.current)

Loading…
Cancel
Save