Prev | Current Page 215 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

Float:
class Account < ActiveRecord::Base
validates_numericality_of :Account_Age
end
Like many of the other validation methods, validates_numericality accepts the :message,
:on, :allow_nil, and :if options. You can also specify :only_integer => true if you want to
ensure that the value is specifically an integer (in this case, the value is tested against the regular
expression /^[+\-]?\d+$/). The default :only_integer => false uses the Kernal.Float
conversion to test if the value is a number.
CHAPTER 4 ?–  CORE FEATURES OF ACTIVE RECORD 88
Your Core Is Strong
You??™ve now been exposed to all three of what we view to be the core features and biggest
advantages of Active Record. Hopefully, you feel pretty comfortable with all the concepts, but
as we??™ve mentioned before, real-world practice of these concepts and techniques is what will
truly make you an expert. So if you haven??™t already picked an Active Record project of your
own to play around with, we suggest you do that now and start getting your feet wet.
In any case, you??™ve completed your initial Active Record training.


Pages:
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227