I''m hip to the naming conventions in ruby, but not completely convinced how they translate when creating boolean database fields in Rails. For example, if I want to be able to call ''approved?'' on a model, I presume the standard would be to create a boolean attribute named ''approved''. But sometimes the lack of the question mark in the database field name makes the meaning of the field name ambiguous, at least to me. Does anyone take or recommend a different approach, such as naming the db field ''is_approved'' and then adding ''def approved?; is_approved?; end'' to the model? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 23, 2007, at 2:46 PM, Robert Head wrote:> > Does anyone take or recommend a different approach, such as naming the > db field ''is_approved'' and then adding ''def approved?; is_approved?; > end'' to the model? >What you just described here is what I generally do. I have always liked to have boolean/bit values represented by some sort of question. is_approved, is_active, etc. Then in my model, I''d define a method approved?, active?, etc. That''s just me, though. Peace, Phillip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---