You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
I discovered an incompatibility in how dm-rails consumes empty Strings, from select/option form fields. When a select form field is left unselected, the submitted value is always an empty String. ActiveRecord would treat empty Strings as nil values, when populating attributes. dm-rails should not map all empty Strings to nil, but only for Integer properties that allowsnil.
The text was updated successfully, but these errors were encountered:
There is what I ended up doing for workaround this issue:
module DataMapper
class Property
class Integer
def typecast_to_primitive(value)
# filters out empty Strings for properties that allow nil
unless (allow_nil? && value.blank?)
typecast_to_numeric(value,:to_i)
end
end
end
end
end
@tpitale Yes. I use the following code in one of my form:
<%= select("foo", "bar_id", Bar.all.collect {|r| [ r.label, r.id ] }, { :include_blank => true }) %>
I discovered an incompatibility in how dm-rails consumes empty Strings, from
select
/option
form fields. When aselect
form field is left unselected, the submitted value is always an empty String. ActiveRecord would treat empty Strings asnil
values, when populating attributes. dm-rails should not map all empty Strings tonil
, but only for Integer properties that allowsnil
.The text was updated successfully, but these errors were encountered: