at. at. - 8 months ago 77
Ruby Question

Using question mark character in Rails/ActiveRecord column name

In keeping with Ruby's idiom of using a question mark in boolean methods (e.g.

), I'd like to do the same for an ActiveRecord field in Rails:

rails generate model Person is_smart?:boolean

I haven't actually run the above statement. I assume that database fields can't have a question mark in them. Will rails deal with this appropriately? Is the best practice to simply leave question marks off of models?

Using Rails 3.2.8


Rails will automatically generate the method smart? if there is a field named 'smart'.