Another way would add another annotation method to ActiveRecord::Base, like:

boolean_field :incomplete, :disabled, :deleted

This would further document the model mapping and would also allow better semantics.

Not that I really care about this as I don't even use ActiveRecord ;)

Cheers,
Rodrigo.

Em 31-05-2012 11:56, Rafael Mendonça França escreveu:
And in these cases you don't know if these fields are boolean or not. If you are choose to store the visible column as string ["yes", "no] so you will not have the query method.

I like this method as it is. For me it is very useful and give me the possibility to not care about what is the datatype of the field.

Rafael Mendonça França
http://twitter.com/rafaelfranca
https://github.com/rafaelfranca



On Thu, May 31, 2012 at 11:52 AM, Rodrigo Rosenfeld Rosas <rr.ro...@gmail.com <mailto:rr.ro...@gmail.com>> wrote:

    Em 31-05-2012 11:48, Maksym Melnychok escreveu:

        @ Rafael Mendonça França

        legacy databases storage must be concern of corresponding database
        adapter, if a field is of boolean type, whatever that means on
        storage
        level of particular database, that field must be treated as
        boolean in rails
        on the model level.

        i'm not suggesting to drop such functionality for boolean
        attributes, only
        for non-booleans where #{attribute}? literally makes no sense
        when you
        read it.

        methods count would be decreased because rails would generate
        query
        method only for boolean attributes.


    I guess Rafael meant another thing. You have boolean fields in
    PostgreSQL but someone might prefer to use some old ANSI types,
    like INTEGER for storing such booleans for some reason.


--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to