Set the model readonly
class MyModel < ActiveRecord::Base def initialize(*args) super(*args) readonly! end end
Set the model readonly
class MyModel < ActiveRecord::Base def initialize(*args) super(*args) readonly! end end
Andrew Timberlake wrote:
Set the model readonly
class MyModel < ActiveRecord::Base def initialize(*args) super(*args) readonly! end end
Wouldn't this make all records of the table read only? I don't think that's what the OP wanted.
I'd say use the the before_destroy callback to validate the deletion:
def before_destroy !project_name.eql?("No project") end
Thanks everyone for your input. Yes I did only want to protect one of the records so ill give your (roberts) method a shot!
thank you very much