ActiveRecord Defaults plugin

Plugin details

Allow you to easily specify default values for attributes on new model objects.

Repositoryhttp://svn.viney.net.nz/things/rails/plugins/active_record_defaults/ Author Jonathan Viney Tags default, ActiveRecord LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://svn.viney.net.nz/things/rails/plugins/active_record_defaults/

Eg:

  class Person < ActiveRecord::Base
    defaults :country => 'New Zealand', :type => 'Unknown', :address => proc { Address.new }
    
    default :last_name do |person|
      person.first_name
    end
  end


The default value is only used if the attribute is not present in the attributes hash.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, about 1 year ago