redinger / validation_reflection

This plugin adds reflective access to validations
http://rubygems.org/gems/validation_reflection
MIT License
296 stars 18 forks source link

*Impossible* to customize ::ActiveRecordExtensions::ValidationReflection.reflected_validations #2

Closed grimen closed 15 years ago

grimen commented 15 years ago

In the README there are instructions for customizing ::ActiveRecordExtensions::ValidationReflection.reflected_validations, but I failed to do so and by the look of the code I can't see how that's even possible. When validation_reflection.rb is required - ::ActiveRecordExtensions::ValidationReflection#install gets called (end of file) and it's too late, but if you try to put the stuff in the config/plugin/validation_reflection.rb, the #reflected_validations gets overwritten anyways. There's pleny of ways to solve this easy, but GitHub don't allow me to fork certain projects right now (github bug), so can't really send a patch yet.

grimen commented 15 years ago

This actually appears when running tests as well:

/opt/local/bin/ruby -I"lib:lib" "/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/validation_reflection_test.rb" 
./test/validation_reflection_test.rb:20:in `<<': can't modify frozen array (TypeError)
    from ./test/validation_reflection_test.rb:20
    from ./test/validation_reflection_test.rb:18:in `class_eval'
    from ./test/validation_reflection_test.rb:18
    from /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
    from /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
    from /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
    from /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5

Also, I suggest using initializer convention (config/initializers/...) instead of config/plugins/....

redinger commented 15 years ago

Yeah, you found some cruft that's been there for a while. Thanks for the commit! Merged.