Skip to content

validate_associated #133

Closed
calebthompson opened this Issue Jul 17, 2012 · 17 comments
@calebthompson
thoughtbot, inc. member

It would be nice to have a validate_associated matcher for AR::Resources.

The options for validates_associated are:

  • :message - A custom error message (default is: "is invalid")
  • :on - Specifies when this validation is active. Runs in all validation contexts by default (+nil+), other options are :create and :update.
  • :if - Specifies a method, proc or string to call to determine if the validation should occur (e.g. :if => :allow_validation**, or **:if => Proc.new { |user| user.signup_step > 2 }). The method, proc or string should return or evaluate to a true or false value.
  • :unless - Specifies a method, proc or string to call to determine if the validation should not occur (e.g. :unless => :skip_validation, or :unless => Proc.new { |user| user.signup_step <= 2 }). The method, proc or string should return or evaluate to a true or false value.

...so it would be cool if there were methods on the matcher to accomodate those.

https://github.com/rails/rails/blob/master/activerecord/lib/active_record/validations/associated.rb

@drapergeek
thoughtbot, inc. member

I like this idea, would love to see a PR.

@drapergeek drapergeek closed this Sep 21, 2012
@calebthompson
thoughtbot, inc. member

Yeah, sorry about that. Got lost along the way.

@drapergeek
thoughtbot, inc. member

Not really your fault, its been in the queue a while.

@westonplatter

👍

@col
col commented May 25, 2013

👍

@direction

👍

@fotanus
fotanus commented Aug 7, 2013

👍

@Pickachu

👍

@mcmire
mcmire commented Oct 23, 2013

I'm going to go ahead and re-open this, given we have interest. PR welcome.

@mcmire mcmire reopened this Oct 23, 2013
@drapergeek
thoughtbot, inc. member

I don't think you should reopen this. Having an issue open doesn't do anything other than add a number to the count. I'm happy to take a PR but having it as an issue doesn't make sense.

@mcmire
mcmire commented Oct 23, 2013

Okay... I just wanted to keep track of what still needs work. Is there another way you like to do this? I don't really tend to look through the "closed" list but maybe that's what I should just do?

@drapergeek
thoughtbot, inc. member

I rarely see things in the issues like this actually being picked up and worked on and the queue for that is pretty big. I see your reasoning but it kind of feels like buying a treadmill that stays in the garage that you keep meaning to sell because you never use it. Does that make sense?

@mcmire
mcmire commented Oct 23, 2013

Sure. I'll assign it to myself, then, so I know that this exists.

@mcmire mcmire closed this Oct 23, 2013
@mcmire mcmire was assigned Oct 23, 2013
@san983
san983 commented May 26, 2015

👍

@vfonic
vfonic commented Nov 11, 2015

👍

I think it's pretty common to keep the issue open until it's resolved. Also, someone searching for an answer, can see that this issue is still open. It saves time.

@wjdhamilton

👍 Agreed

@lifeiscontent

@mcmire any updates here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.