Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

OrderedHash as collection not recognized as Hash #49

Closed
dbackeus opened this Issue · 2 comments

3 participants

@dbackeus

For hard coded options for select fields I like to go with hashes since they map very nicely to the select option concept (key -> values). But since the Ruby 1.8 hash is not ordered I always use OrderedHash instead (sudo gem install orderedhash).

Formtastic didn't recognize it as a Hash at line 1075 of formtastic.rb:
collection = collection.to_a if collection.instance_of?(Hash)

I did a simple local hack and changed instance_of? to is_a?:
collection = collection.to_a if collection.is_a?(Hash)

So now the OrderedHash'es are working just fine as hashes. I didn't run any test suites against it or anything. If you agree it's a good idea I hope to see it in master.

@grimen

is_a? is "in most cases" what one wants for this kind of checks, yes. +1

@justinfrench

fixed in 40dc631, thanks!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.