Naming Boolean Columns in Rails

Say I have a Dog , and I want to save if it is trained in Rails. Typically, Ruby methods that return boolean names have names ending in ? . Should I call the trained? database column trained? , or should I call the trained database column and have a method

 class Dog def trained? trained end end 

The latter option seems inefficient, especially when I have a lot of logical fields.

Or is there some other alternative that I am missing?

+40
ruby ruby-on-rails
06 Oct '09 at 7:53
source share
1 answer

You must call it trained. Define it in your schema with type: boolean. Can you call him trained? and everything will magically work. So says http://www.ruby-forum.com/topic/60847

+63
Oct. 06 '09 at 8:02
source share



All Articles