Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to modify configuration options #3

Open
dce opened this issue Jun 18, 2015 · 0 comments
Open

Add ability to modify configuration options #3

dce opened this issue Jun 18, 2015 · 0 comments

Comments

@dce
Copy link
Member

dce commented Jun 18, 2015

On a recent project, I needed to prevent admins from deleting photos that are attached to other models. In a normal ActiveRecord model, this is pretty easy to do -- has_many :photo_attachments, dependent: :restrict_with_error. Since I'm using SP, though, I had to do this:

class Photo < ActiveRecord::Base
  extend SimplestPhoto::Model::Photo

  def destroy
    if photo_attachments.any?
      errors.add :base, "Photo has attachments and cannot be destroyed"
      return false
    end

    super
  end
end

It would be nice for there to be some way to modify the options SP uses, though I don't have any brilliant ideas of how to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant