markgandolfo / find_list

Find List is a ruby on rails plugin to return an array from activerecord in a format that f.select likes

This URL has Read+Write access

radar (author)
Wed Jun 03 17:44:28 -0700 2009
markgandolfo (committer)
Wed Jun 03 17:49:52 -0700 2009
commit  cb68edb5e953b75c0807f73c17a29671574062de
tree    ee154f983532e0a94dfe51466a9c91bb6ca210a6
parent  80a16ce6ff495bffd73303fd7b323798a291f9c6
find_list / README.markdown
100644 31 lines (14 sloc) 0.699 kb

FindByList

Little plugin that will return an array from an Active Record object ready to use in a select By default it uses the 'id' as the value and 'name' as the display field.

Example

To get all users User.list

If you want to select different fields for the list plugin to use, you can simply do

User.list(:id => 'another_id_field', :display => 'firstname')

Standard activerecord :conditions tags can also be used

User.list(:conditions => { :active => 1 } )

Or to put everything together

User.list(:id => 'another_id_field', :display => 'firstname', :conditions => { :active => 1 })

Copyright

Copyright (c) 2009 Mark Gandolfo, released under the MIT license