Jun'uary
Jan'uary » 日志 » [Announce] ActsAsOptions
[Announce] ActsAsOptions
Jan 发表于 2008-04-17 15:43:11
ActsAsOptions
=============
This plugin make model acts like select options
Installation
------------
In your rails directory:
script/plugin install http://janx.googlecode.com/svn/trunk/acts_as_options
How To Use
----------
After installed, add the 'acts_as_options' line to your model:
class Brand
acts_as_options
end
By default ActsAsOptions suppose you have a 'name' column and a 'id' column in your table, you can change this of course(see below).
After the declaration whenever you need options for a select in form, simply:
f.select :brands, Brand.find_as_options
or
select_tag :brands, Brand.find_as_options
you can specify the name and value column when declaration or find:
acts_as_options :stub, :id # will generate <option value='<%= brand.id %>'><%= brand.stub %></option>
Brand.find_as_options :stub, :id
=============
This plugin make model acts like select options
Installation
------------
In your rails directory:
script/plugin install http://janx.googlecode.com/svn/trunk/acts_as_options
How To Use
----------
After installed, add the 'acts_as_options' line to your model:
class Brand
acts_as_options
end
By default ActsAsOptions suppose you have a 'name' column and a 'id' column in your table, you can change this of course(see below).
After the declaration whenever you need options for a select in form, simply:
f.select :brands, Brand.find_as_options
or
select_tag :brands, Brand.find_as_options
you can specify the name and value column when declaration or find:
acts_as_options :stub, :id # will generate <option value='<%= brand.id %>'><%= brand.stub %></option>
Brand.find_as_options :stub, :id
曾经的这一天...
- » 2007年: 今天收到了Joost的邀请
- » 2006年: Google Video前100名
- » 2006年: 域名是21世纪的房地产
- » 2006年: Google的物理构造
相关日志:
收藏:
QQ书签
del.icio.us
订阅:
Google
抓虾
