Method: Perus::Server::Form#association
- Defined in:
- lib/perus/server/form.rb
#association(field, options) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/perus/server/form.rb', line 46 def association(field, ) reflection = @record.class.association_reflections[field.to_sym] other_model = reflection[:class_name].constantize id_field = reflection[:key] values = other_model.all.collect do |record| [record.id, record.name] end select(id_field, values) end |