Provide a way to set the Rails field_error_proc #896

Closed
tokland opened this Issue Nov 5, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@tokland
Contributor

tokland commented Nov 5, 2012

(Coming from #39) We can easily set a custom field_error_proc with:

Formtastic::Helpers::FormHelper::FIELD_ERROR_PROC = ::ActionView::Base.field_error_proc

But this gives the typical "warning already initialized constant". To fix this nuisance we can write:

module Formtastic::Helpers::FormHelper
  remove_const :FIELD_ERROR_PROC
  FIELD_ERROR_PROC = ActionView::Base.field_error_proc
end 

However, to avoid this kind of hacks I'd propose to expose the proc as a module variable (mattr_accessor like the others), so coders can set its own in a clean way.

@justinfrench

This comment has been minimized.

Show comment Hide comment
@justinfrench

justinfrench Nov 7, 2012

Owner

Would love to see a pull request for this!

Owner

justinfrench commented Nov 7, 2012

Would love to see a pull request for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment