How can I set a model to be read-only every time that it is accessed if an attribute within the same model is set to true?
I have looked everywhere and the model read only seems to have very little documentation and even web results.
Edit (Additional Info): I have two methods in my Model (application.rb) - not in private
def lock()
self.locked = true
save(validate: false)
end
def unlock()
self.locked = false
save(validate: false)
end
I call them from my applications controller on update with:
if params[:application][:locked] == false
@application.unlock
return
elsif params[:application][:locked] == true
@application.lock
return
end
and in the Model (application.rb) I have - not in private:
def readonly?
locked == true
end