vigetlabs / simplest_photo

Attach photos to your models
MIT License
1 stars 2 forks source link

Accept Additional Validation Options #5

Closed h0tl33t closed 9 years ago

h0tl33t commented 9 years ago

The goal of this PR is to allow users to pass through additional validation options aside from required: true. I ran into a case where I need to seed records that are not user-creatable, but users should be able to update with photos and other things that are required on update.

Basically, I'd like us to be able to do the following:

has_photo :hero_image, required: true, on: :update
yaychris commented 9 years ago

Looks fine, though I'm kinda bummed about losing the keyword args. Is there a need to pass options other than on? If not, I'd rather add a keyword arg for it (docs indicate nil is the default value for on, so this should be fine).

def has_photo(name, required: false, on: nil)
h0tl33t commented 9 years ago

Not at this point. My use case was just for :on, so if we can pass nil for default, I'll update this to use keyword args like you suggested.