Is your plugin hosted on GitHub? Make sure to press the "fetch" button next to the repository field to fetch your plugin's info from GitHub rather than typing it all in.
Repository
Name
Home Page
Short description Allows you to prevent particular database fields from being changed after a record is created. A validation error occurs on updates if an attribute of a model object is different from its value in the database.
Description === Introduction This RubyGem and Rails plugin adds a +validates_constancy_of+ validation to Active Record. It allows you to prevent particular database fields from being changed after a record is created. A validation error occurs on updates if an attribute of a model object is different from its value in the database. === Installing Validates Constancy The code is packaged as both a RubyGem and a Rails plugin. You can use either one, depending on what your needs are. <b>The Validates Constancy gem</b> is compatible with various versions of Rails (Active Record) -- see the _test_ subdirectories of http://constancy.rubyforge.org/svn/gem/branches. You can install the gem with the command: gem install validates_constancy <b>The Validates Constancy plugin</b> is compatible with the latest released version of the Rails framework (and possibly also other versions -- see http://constancy.rubyforge.org/svn/plugin/test). You can install the plugin with the command: ruby script/plugin install http://constancy.rubyforge.org/svn/plugin/validates_constancy Use the gem (http://constancy.rubyforge.org/svn/gem) if you're using Active Record apart from Rails, or for compatibility with a version of Rails (Active Record) that is not supported by the plugin. Use the plugin if your Rails version is up to date and if you like the convenience of a Rails plugin. === Using constancy validation Here's how to use this validation in your code. class Person < ActiveRecord::Base # Prevent changes to Person#social_security_number. validates_constancy_of :social_security_number end ==== Options The validation takes two options, <tt>:if</tt> and <tt>:message</tt>. These may be familiar because several of Active Record's validations also use them. The <tt>:if</tt> option takes a Proc, or a symbol, or string with a model object argument and a return value of +true+ or +false+. class Comment < ActiveRecord::Base # Prevent changes to Comment#text if it is "locked." validates_constancy_of :text, :if => Proc.new { |comment| comment.locked? } end The default error message is "can't be changed". Use your own error message by specifying the <tt>:message</tt> option. class LicensePlate < ActiveRecord::Base # Prevent changes to LicensePlate#number. validates_constancy_of :number, :message => 'is off-limits! What are you thinking?' end More than one model attribute can be specified. Any specified options will be applied to all the specified attributes. ==== Warning With associations, validate the constancy of a foreign key, not the instance variable itself: <tt>validates_constancy_of :invoice_id</tt> instead of <tt>validates_constancy_of :invoice</tt>. Also note the warning under <em>Inheritable callback queues</em> in http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html. "In order for inheritance to work for the callback queues, you must specify the callbacks before specifying the associations. Otherwise, you might trigger the loading of a child before the parent has registered the callbacks and they won't be inherited." Validates Constancy uses these callback queues, so you'll want to specify associations *after* +validates_constancy_of+ statements in your model classes. === Running automated tests for Validates Constancy There's a suite of tests that exercises all the functionality of Validates Constancy. You can check out a version of the test suite from the repository according to the version of Rails (Active Record) it works with. ==== Gem [<b>Rails v1.2.2 (Active Record v1.15.2)</b>] Check out http://constancy.rubyforge.org/svn/gem/branches/branch_1-x/test/rails_1-2-2 [<b>Rails v1.2.3 (Active Record v1.15.3)</b>] Check out http://constancy.rubyforge.org/svn/gem/branches/branch_1-x/test/rails_1-2-3 [<b>Rails v1.2.4 (Active Record v1.15.4)</b>] Check out http://constancy.rubyforge.org/svn/gem/branches/branch_1-x/test/rails_1-2-4 [<b>Rails v1.2.5 (Active Record v1.15.5)</b>] Check out http://constancy.rubyforge.org/svn/gem/branches/branch_1-x/test/rails_1-2-5 [<b>Rails v1.2.6 (Active Record v1.15.6)</b>] Check out http://constancy.rubyforge.org/svn/gem/branches/branch_1-x/test/rails_1-2-6 [<b>Rails v2.0.0 (Active Record v2.0.0)</b>] Check out http://constancy.rubyforge.org/svn/gem/branches/branch_1-x/test/rails_2-0-0 [<b>Rails v2.0.1 (Active Record v2.0.1)</b>] Check out http://constancy.rubyforge.org/svn/gem/branches/branch_1-x/test/rails_2-0-1 [<b>Rails v2.0.2 (Active Record v2.0.2)</b>] Check out http://constancy.rubyforge.org/svn/gem/branches/branch_1-x/test/rails_2-0-2 [<b>Edge Rails</b>] Check out http://constancy.rubyforge.org/svn/gem/branches/branch_1-x/test/rails_edge ==== Plugin [<b>Rails v1.2.2 (Active Record v1.15.2)</b>] Check out http://constancy.rubyforge.org/svn/plugin/test/rails_1-2-2 [<b>Rails v1.2.3 (Active Record v1.15.3)</b>] Check out http://constancy.rubyforge.org/svn/plugin/test/rails_1-2-3 [<b>Rails v1.2.4 (Active Record v1.15.4)</b>] Check out http://constancy.rubyforge.org/svn/plugin/test/rails_1-2-4 [<b>Rails v1.2.5 (Active Record v1.15.5)</b>] Check out http://constancy.rubyforge.org/svn/plugin/test/rails_1-2-5 [<b>Rails v1.2.6 (Active Record v1.15.6)</b>] Check out http://constancy.rubyforge.org/svn/plugin/test/rails_1-2-6 [<b>Rails v2.0.0 (Active Record v2.0.0)</b>] Check out http://constancy.rubyforge.org/svn/plugin/test/rails_2-0-0 [<b>Rails v2.0.1 (Active Record v2.0.1)</b>] Check out http://constancy.rubyforge.org/svn/plugin/test/rails_2-0-1 [<b>Rails v2.0.2 (Active Record v2.0.2)</b>] Check out http://constancy.rubyforge.org/svn/plugin/test/rails_2-0-2 [<b>Edge Rails</b>] Check out http://constancy.rubyforge.org/svn/plugin/test/rails_edge Then read rails_*/doc/README_FOR_APP for instructions on how to run the tests.
Description format RDoc MarkDown Textile
License Ruby's Rails' (MIT) GPL LGPL BSD Apache Artistic PublicDomain BSD-type Free-Trial Free-but-Restricted OpenSource Proprietary Shareware Source-available-proprietary Commercial
Category Assets Controllers Internationalization Misc. Enhancements Model Rails Engines Searching and Queries Security Statistics and Logs Testing View Extensions