Skip to content

Commit

Permalink
Merge pull request bootstrap-ruby#228 from kieranklaassen/master
Browse files Browse the repository at this point in the history
Fix a crash when using form for Ransack
  • Loading branch information
potenza committed Jun 5, 2015
2 parents f190562 + 56dfe37 commit c7af9f1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/bootstrap_form/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,12 @@ def required_attribute?(obj, attribute)
return false unless obj and attribute

target = (obj.class == Class) ? obj : obj.class
target_validators = target.validators_on(attribute).map(&:class)

target_validators = if target.respond_to? :validators_on
target.validators_on(attribute).map(&:class)
else
[]
end

has_presence_validator = target_validators.include?(
ActiveModel::Validations::PresenceValidator)
Expand Down

0 comments on commit c7af9f1

Please sign in to comment.