Wrote up a quick validator today to ensures a field isn't changed after the 
record is created:


class ModelBase
  # depends on Dirty plugin: 
http://www.rubydoc.info/gems/sequel/Sequel/Plugins/Dirty
  def validates_unchanged(attribute)
    errors.add(attribute, 'cannot be modified') if !new? and column_changed
?(attribute)
  end
end

class Model < ModelBase
  def validate
    validates_unchanged :username
  end
end

https://gist.github.com/odigity/e33fd1b31fd26167a120

-ofer

-- 
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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to