On Thursday, September 29, 2016 at 4:41:22 PM UTC-7, Tom Wardrop wrote:
>
> Maybe read-only is the wrong word. I basically just want to prevent 
> changes from being saved. #freeze may be a step too far as I don't 
> necessarily care if the data changes, as long as it's not committed to the 
> database.
>
> On Friday, 30 September 2016 09:39:41 UTC+10, Tom Wardrop wrote:
>>
>> Is it possible to make a Model, either at the class or instance level 
>> (preferrably class) read-only? Well, of course it's possible, so maybe I 
>> should ask, what's the best method of doing this, e.g. a #validate method 
>> that always return false, a before_save hook that throws an exception?
>>
>>
The best way to handle this is to use a database account that has read only 
access.

If you don't want to do that, you can override `Model#save` and 
`Model#delete` for the class to raise an exception.  However, that doesn't 
prevent all change to the model's table, only ones that use the model's 
save/delete and related methods.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to