Navigation Menu

Skip to content

Commit

Permalink
Minor fixes to get formstastic to be ruby 1.9 compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
hectoregm authored and justinfrench committed Apr 18, 2009
1 parent af6e275 commit 045626a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/formtastic.rb
Expand Up @@ -701,7 +701,14 @@ def inline_input_for(method, options)
def inline_errors_for(method, options) #:nodoc:
return nil unless @object && @object.respond_to?(:errors) && [:sentence, :list].include?(@@inline_errors)

errors = @object.errors.on(method.to_s).to_a
# Ruby 1.9: Strings are not Enumerable, ie no String#to_a
errors = @object.errors.on(method.to_s)
unless errors.respond_to?(:to_a)
errors = [errors]
else
errors = errors.to_a
end

send("error_#{@@inline_errors}", errors) unless errors.empty?
end

Expand Down Expand Up @@ -773,6 +780,8 @@ def field_set_and_list_wrapping(html_options, contents='', &block) #:nodoc:

contents = template.capture(&block) if block_given?

# Ruby 1.9: String#to_s behavior changed, need to make an explicit join.
contents = contents.join if contents.respond_to?(:join)
fieldset = template.content_tag(:fieldset,
legend + template.content_tag(:ol, contents),
html_options.except(:builder, :parent)
Expand Down

0 comments on commit 045626a

Please sign in to comment.