Browse files

No longer assumes the form's object responds to :errors. Sometimes we…

… don't use ActiveRecord models as form objects.
  • Loading branch information...
1 parent 02a2c2e commit b700aca0fed8ad8b7167a0e029b0d389424081d8 @airblade committed Oct 23, 2008
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/air_blade/air_budd/form_builder.rb
View
3 lib/air_blade/air_budd/form_builder.rb
@@ -299,6 +299,7 @@ def button(purpose = :save, options = {}, html_options = {})
end
def method_missing(*args, &block)
+ # Button method
if args.first.to_s =~ /^(new|save|cancel|edit|delete)$/
button args.shift, *args, &block
else
@@ -373,7 +374,7 @@ def addendum_element(options = {})
end
def errors_for?(method)
- @object && @object.errors[method]
+ @object && @object.respond_to?(:errors) && @object.errors[method]
end
end

0 comments on commit b700aca

Please sign in to comment.