Plugin: selection_options_for

Many selection lists in an application do not change and so the quickest way to code them is to put the list in the code itself. For example:

  • Child, Adult, or Senior.
  • Male or Female.
  • Yes or No.

selection_options_for manages static selection lists. If you selection lists are dynamically generated this is not the answer.

selection_options_for allows you to

  • keep the display labels in the model
  • store a 1 character flag in the DB
  • test the value with methods in the code
class Article < ActiveRecord::Baseselection_options_for :file_type_option,[ :pdf, 'PDF'],[ :hmlt, 'HTML'],[ :text, 'X', 'Textfile']end # class

Then you can do stuff like ....

  assert   file_type_option_pdf?

OR

   

More examples are in the README file. Code available here ... or use ...

svn export --username anonymous http://agiledna.com/svn/pub/plugins/selection_options_for/trunk selection_options_for

Thanks to Scott Barron for code review and tips on tightening up the code.

Related post:

Multi-select lists boxes in Rails


-- Mark Windholtz

New Live Site: Scrum Alliance

Yet another site built by AgileDNA enters production.

The Scrum Alliance is a non-profit organization committed to delivering facilities, stories, courses, and other materials that will help Scrum users be successful.

The Scrum Alliance's mission is to promote increased awareness and understanding of Scrum, provide resources to individuals and organizations using Scrum, and support the iterative improvement of the software development profession.

The Scrum Alliance founders are: Ken Schwaber, Mike Cohn, and Esther Derby.

Scrum is an iterative, incremental process for developing any product or managing any work. It produces a potentially shippable set of functionality at the end of every iteration

Scrum Alliance


-- Mark Windholtz

New Live Site: Agile Alliance

A new AgileDNA constructed site enters production.

The Agile Alliance is a non-profit organization that supports individuals and organizations who use agile approaches to develop software. Driven by the simple priorities articulated in the Manifesto for Agile Software Development, agile development approaches deliver value to organizations and end users faster and with higher quality.


-- Mark Windholtz

Edge Rails (aka 1.2) reaper

If your working with Edge Rails (the soon to be Rails 1.2) you may have noticed that the *-d* option for script/process/reaper has gone away.


Read Full Entry ...

-- Mark Windholtz