I searched the git history and couldn't find anything.  Do you have any 
other details?

My specific need has arisen not from ActiveRecord or a model, but 
transmitting data through to an API.  Occasionally, the way we ask a 
question requires an inversed update to the API.  i.e. the user answers 
"Yes" and we need to submit `false` to the API.  We've been proactive about 
testing value equality, but I thought this would be an easier 
implementation and might be useful to the community.

On Monday, April 4, 2016 at 8:45:52 AM UTC-5, Mohamed Wael Khobalatte wrote:
>
> Yes, actually Rails did have a TRUTHY_VALUES collection, similar to the 
> false collection now, but I don't remember why they deprecated it. Maybe 
> looking into that might address some of your issues. 
>
> On Mon, Apr 4, 2016 at 3:43 PM, Clayton Liggitt <[email protected] 
> <javascript:>> wrote:
>
>> String already converts itself to other types.  "4".to_i becomes the 
>> Integer 4.  Invalid values, other than the ones listed (like "foobar") 
>> would raise an argument error.
>>
>> Wael, thanks for the reference to ActiveModel!  This is definitely 
>> similar.  Would this implementation be better for everyone?  I would like 
>> to be explicit about true/false values, whereas the implementation in 
>> ActiveModel only has explicit false types.  I feel this belongs on 
>> ActiveSupport because it's commonly included on other projects (including 
>> ActiveModel), and has no further dependencies.
>>
>> On Monday, April 4, 2016 at 4:23:51 AM UTC-5, Mohamed Wael Khobalatte 
>> wrote:
>>>
>>> Conversion between types is fairly common in Ruby. With that said I'd 
>>> recommend you look into `ActiveModel::Type::Boolean.new.cast(my_value)`, 
>>> which handles the all cases above.
>>>
>>> On Mon, Apr 4, 2016 at 10:31 AM, Greg Navis <[email protected]> 
>>> wrote:
>>>
>>>> Hey!
>>>>
>>>> I think this would cause confusion. First, the logical values of 
>>>> `string` and `string.to_bool` would be different. Second, what would you 
>>>> return for a string "foobar"?
>>>>
>>>> Best regards
>>>> -- 
>>>> Greg Navis
>>>> I help small software companies to scale Heroku-hosted Rails apps.
>>>> Free, biweekly scalability newsletter for SaaS CEOs 
>>>> <http://www.gregnavis.com/newsletter/>
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Ruby on Rails: Core" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at https://groups.google.com/group/rubyonrails-core.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> -- 
>>> Wael Khobalatte
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby on Rails: Core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/rubyonrails-core.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Wael Khobalatte
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to