On Feb 22, 2013, at 3:53 AM, dosadni...@gmail.com wrote: > > https://gist.github.com/bbozo/5006180 > > This would allow us to handle highly specific controller-introduced > validators inside the controller and without adding unnecessary bloat in > other areas (usually in unit test factories and with_options :if => > some_roundabout_way_of_detecting_which_controller_youre_on block spam in the > model).
What's wrong with something like this: class SomeModel attr_accessor :validate_the_thingy validate :make_one_particular_and_unique_thingy_go_red, :if => :validate_the_thingy end in the controller: @some_model = SomeModel.some_factory_method(params) @some_model.validate_the_thingy = true In both cases, the validation method is sitting around on the model. I'd argue that this "breaks MVC" *less* than the solution in your Gist, since this keeps the flag separate from its implementation, rather than having the controller poke extra validations (by method name) directly into the model instance. If you've *really* got bunches of wildly divergent validation setups, I'd agree with the suggestion on the ticket to actually create a (plain Ruby) mediator object and use the ActiveModel APIs. --Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.