# \[ANN\] ActsAsOptions plugin for Rails 2.0

**URL:** <https://www.ruby-forum.com/t/ann-actsasoptions-plugin-for-rails-2-0/135278>\
**Category:** Rails\
**Created:** [April 20, 2008, 2:07pm UTC](https://www.ruby-forum.com/t/ann-actsasoptions-plugin-for-rails-2-0/135278 "2008-04-20T14:07:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flowerborn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/d9b06d/32.png) [@flowerborn](https://www.ruby-forum.com/u/flowerborn)\
**Post date:** [April 20, 2008, 2:07pm UTC](https://www.ruby-forum.com/t/ann-actsasoptions-plugin-for-rails-2-0/135278/1 "2008-04-20T14:07:26Z")

</div>

Hi,

I’ve made a simple plugin for Rails 2.0 to generate options for   
tag.

script/plugin install  
[http://janx.googlecode.com/svn/trunk/acts\_as\_options](http://janx.googlecode.com/svn/trunk/acts_as_options)

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 \<%= brand.stub %\>

or

Brand.find\_as\_options :stub, :id

Best  
Jan
