没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > janx |
janx
|
0 | 0 | 3 |
贡献者 | 讨论 | 代码提交 |
概述
ActsAsOptionsThis plugin make model acts like select options
InstallationIn your rails directory:
script/plugin install http://janx.googlecode.com/svn/trunk/acts_as_options
How To UseAfter installed, add the 'acts_as_options' line to your model:
class Brand
acts_as_options
endBy 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_optionsor
select_tag :brands, Brand.find_as_optionsyou can specify the name and value column when declaration or find:
Specify when declare:
acts_as_options :stub, :id # will generate Specify when use: Brand.find_as_options :stub, :id
创建时间:2014-05-06 18:38