Skip to content

Commit

Permalink
Added check in generate_validations to ensure that the object respond…
Browse files Browse the repository at this point in the history
…s to _validators; some forms can be built around non ActiveModel objects (eg Authlogic::Session::Base)
  • Loading branch information
Nicholas Firth-McCoy committed Mar 17, 2011
1 parent c6255ee commit 13124ac
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/better_form/builder.rb
Expand Up @@ -44,6 +44,10 @@ def generate_label(method, label)

def generate_validations(object, attribute)
validations = {}

# Don't try to add validations for an object that doesn't have _validators
return {} unless object.respond_to?(:_validators)

# Iterate over each validator for this attribute, and add the appropriate HTML5 data-* attributes
object._validators[attribute].each do |validator|
validation = case validator
Expand Down

0 comments on commit 13124ac

Please sign in to comment.