Easy Selects in Ruby on Rails


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1.  
  2. module ActiveRecord
  3. class Base
  4. def self.to_select(conditions = nil)
  5. find(:all).collect { |x| [x.name,x.id] }
  6. end
  7. end
  8. end
  9.  
  10. class Array
  11. def to_select
  12. self.collect { |x| [x.name,x.id] }
  13. end
  14. end
  15.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.