model - Setting a field to read-only in Rails after it's created -


I want to protect the user-created entry in a field after an initial build.

I am asking the user for a unique name when it installs a project, and I want to change it after creation.

Is there any way to do this in the train? Can I set it as attr_accessible first and then switch it to attr_protected?

You can add custom verification method to your model:

  # Project Model validate_on_update: forbid_changing_name def forbid_changing_name Errors [: name] = "Can not be changed!" If self.name_changed? End  

Comments