David Hughes
2006-Apr-12 06:05 UTC
[Rails] Select Collection with Conditions - May Help You...
Hey All: Thought I''d pass this along...let me know if you have a better, more elegant way. Still new to Rails, but was fiddling around with the Select Helper trying to return an option collection that was filtered (in other words, I didn''t want every item from the collection, just the ones that met a certain criteria). I used find_all_by_ to do it and it looks like this in my view: <% select ''deal'', ''supplier'', Client.find_all_by_is_supplier(true, :order => ''name'').collect { |c| [c.name, c.id] } %> Note the sort order as well. Hope this helps someone... Cheers, David -- Posted via http://www.ruby-forum.com/.
Possibly Parallel Threads
- How to Pass Jquery selected dropdown values and radio button values to controller
- ActiveRecord 'find_or_initialize_by' dynamic finder bug? Ignoring conditions.
- [LLVMdev] Unexpected failures in the DejaGNU test collection
- find_by_ issue
- how do i get country_select and select to show values