I've got a simple "Log" model, that records the very fact of calling controller's action.
Records of the "log" record are meant to be produced once rather than changed. Also, I'll have a number of these records within the database.
So, there's no requirement for "up-to-date_at" column (don't have to waste the memory on Hard disk drive).
How do i tell to Rails to depart only "produced_at" column and never to make use of "up-to-date_at"?
Can there be in whatever way to create the "Log" model read only?
You may make the model readonly with the addition of a
readonly? approach to the model.
class Log < ActiveRecord::Base # Prevent modification of existing records def readonly? !new_record? end # Prevent objects from being destroyed def before_destroy raise ActiveRecord::ReadOnlyRecord end end
The example above was utilized from here.
If you do not require the
updated_at column, just remove (or don't add it) it out of your database. Rails will not update what's not there.
I presume you will find the
updated_at column since you used the
t.timestamps shorthand inside your model's migration file. If you do not want the column you'll be able to specify that which you do want clearly:
class Log < ActiveRecord::Migration def self.up create_table :logs do |t| t.column :foo, :string t.column :created_at, :datetime end end def self.down drop_table :logs end end