Skip to content

Commit

Permalink
Class name should be a string, not class
Browse files Browse the repository at this point in the history
  • Loading branch information
arr-ee committed Apr 2, 2013
1 parent 9bf286d commit 5310341
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -189,7 +189,7 @@ class UserForm
include ActiveRecord::Validations
attr_accessor :email
validates_uniqueness_of :email, :client_validations => { :class =>
User }
'User' }
end
...
<% form_for(UserForm.new, :as => :user) do %>
Expand Down
2 changes: 1 addition & 1 deletion lib/client_side_validations/active_record/uniqueness.rb
Expand Up @@ -8,7 +8,7 @@ def client_side_hash(model, attribute, force = nil)
hash[:allow_blank] = true if options[:allow_blank]

if options.key?(:client_validations) && options[:client_validations].key?(:class)
hash[:class] = options[:client_validations][:class].name.underscore
hash[:class] = options[:client_validations][:class].underscore
elsif model.class.name.demodulize != model.class.name
hash[:class] = model.class.name.underscore
end
Expand Down
2 changes: 1 addition & 1 deletion test/active_record/cases/test_uniqueness_validator.rb
Expand Up @@ -55,7 +55,7 @@ def test_uniqueness_client_side_hash_when_nested_module
def test_uniqueness_client_side_hash_with_class_from_options
@user = UserForm.new
expected_hash = { :message => "has already been taken", :case_sensitive => true, :class => 'user' }
assert_equal expected_hash, UniquenessValidator.new(:attributes => [:name], :client_validations => { :class => User } ).client_side_hash(@user, :name)
assert_equal expected_hash, UniquenessValidator.new(:attributes => [:name], :client_validations => { :class => 'User' } ).client_side_hash(@user, :name)
end
end

0 comments on commit 5310341

Please sign in to comment.