This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Sun Jul 20 18:25:04 -0700 2008 | [fnando] |
| |
README | Sun Jul 20 20:14:21 -0700 2008 | [fnando] |
| |
init.rb | Sun Jul 20 18:25:04 -0700 2008 | [fnando] |
| |
lib/ | Sun Jul 20 20:14:21 -0700 2008 | [fnando] |
| |
test/ | Sun Jul 20 20:14:21 -0700 2008 | [fnando] |
README
has_defaults
============
Instalation
-----------
1) Install the plugin with `script/plugin install git://github.com/fnando/has_defaults.git`
Usage
-----
1) Add the method call `has_defaults` to your model.
class Page < ActiveRecord::Base
has_defaults :title => "New page", :body => "Put your text here"
end
Attributes will be set only if it's a new record and the attribute is blank.
Retrieve the default attribute with the `default_for` instance method:
@page.default_for(:title)
You can pass Proc as attribute:
has_defaults :expires_at => proc { Time.now }
You can override the default attributes as follow:
Page.has_defaults_options = {:title => "Here's your new page", :body => "Write your page text"}
Copyright (c) 2008 Nando Vieira, released under the MIT license



