byroot / activerecord-typedstore

ActiveRecord::Store but with type definition
MIT License
439 stars 57 forks source link

Support for multi parameters value assigment (date, datetime) #16

Open byroot opened 10 years ago

byroot commented 10 years ago

Fixes #15

CyborgMaster commented 9 years ago

I would love to have something like this work so simple form could infer the data type. Is the build failure a no-go?

byroot commented 9 years ago

I couldn't figure how to make it work sorry :/

CyborgMaster commented 9 years ago

No problem. Thanks for the quick response.

FYI: I solved my particular issue by patching SimpleForm to know about TypedStore instead of rails

# Extend simple form to know about activerecord-typedstore columns
class SimpleForm::FormBuilder
  def find_attribute_column_with_typed_store(attribute_name)
    if @object.class.respond_to?(:typed_store_attributes)
      col = @object.class.typed_store_attributes[attribute_name.to_s]
    end
    col || find_attribute_column_without_typed_store(attribute_name)
  end
  alias_method_chain :find_attribute_column, :typed_store
end
byroot commented 9 years ago

Good to know. Hopefully with the new rails APIs available in 4.2 I might be able to make it work, but it's too soon to be sure.