ActsAsOptions plugin for Rails 2.0


I've made a simple plugin for Rails 2.0 to generate options for <select> tag.

script/plugin install

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: :brands, Brand.find_as_options


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.stub %></option>


Brand.find_as_options :stub, :id

Best Jan