Plugins - ActsAsOptions

StarAdd to favorites

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:

Specify when declare:

acts_as_options :stub, :id # will generate

Specify when use: Brand.find_as_options :stub, :id

Jan X

http://jan.yculblog.com

http://janx.googlecode.com/svn/trunk/

GPL

  • Currently 3.3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Model

Tags

Comments

Add a comment
Tom Harrison 15 May 2008

Not to be negative or anything, but how does this plugin really help compared to the normal select or selecttag or optionsfor_select helpers?

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?