However, there
is a way to create a read-only accessor to get at this data in your model, for use with a legacy
database.
Given a table with the following enum column
`number` enum('ONE','TWO','THREE') NOT NULL default 'ONE'
use the following model with a custom accessor using the attributes_before_type_cast
method to get the column value:
class Klass < ActiveRecord::Base
def number
attr = attributes_before_type_cast
"#{attr['number']}"
end
end
Does Active Record Support Adding Security to Individual
Models or Columns?
Active Record does not include any support for security by default. Fortunately, there are ways
to implement model-level security and plug-ins available that do it for you. One such plug-in
is the ModelSecurity plug-in written by Bruce Perens, which is available at http://perens.com/
FreeSoftware/ModelSecurity.
What Is the Difference Between has_one and belongs_to?
The difference between the two association types is in where the foreign key resides. In short,
belongs_to is used when the related model??™s primary key is stored in the model??™s class, and
has_one is used when the related model??™s primary key is stored in the other model??™s table.
Pages:
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483