I have a model named Business for which I have a uniqueness validation on email. The ajax request gets sent to the url
http://localhost.com/validators/uniqueness?case_sensitive=true&business%5Bemail%5D=mabid.mah%40gmail.com
But it gives me a strange error
uninitialized constant Busines
The s is missing where did it go ? here is the stack trace
activesupport (3.2.3) lib/active_support/inflector/methods.rb:229:in `block in constantize'
activesupport (3.2.3) lib/active_support/inflector/methods.rb:228:in `each'
activesupport (3.2.3) lib/active_support/inflector/methods.rb:228:in `constantize'
activesupport (3.2.3) lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
client_side_validations (3.1.4) lib/client_side_validations/middleware.rb:59:in `is_unique?'
client_side_validations (3.1.4) lib/client_side_validations/middleware.rb:45:in `response'
client_side_validations (3.1.4) lib/client_side_validations/middleware.rb:16:in `call'
Realized this is an issue with rails inflector classify
The classify method does not work with singular names like "Business"
http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-classify
To workaround add the following to your config/initializers/inflections.rb
ActiveSupport::Inflector.inflections do |inflect|
inflect.singular(/ess$/i, 'ess')
end