Prev | Current Page 202 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

This way all applications are
dealing with the same rules and can reasonably expect the data to be in the same format
regardless of its originating source.
CHAPTER 4 ?–  CORE FEATURES OF ACTIVE RECORD 81
This last implementation option really shines a light on the main design decision you
have to make when thinking about implementing data validations??”do you implement them
in Ruby or directly in your database? Before you make your choice, consider these pros and
cons of Active Record validations:
??? Pros: The good news is that because Active Record objects are really just Ruby objects,
Active Record validations are database independent. You don??™t need to know any special
syntax or language such as TSQL or PL/SQL; you just write Ruby methods with
Ruby code. Additionally, the validations occur on the object before data gets mapped
to the database via SQL calls, which means that you save expensive (in terms of bandwidth
and processing) database calls for just those times that you really want them.
??? Cons: The bad news is that Active Record validations are only applied within your Ruby
code.


Pages:
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214