1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00

Add support for when the condition of an association is a proc.

This commit is contained in:
Bradly Feeley 2013-05-25 12:39:07 -07:00
parent 1da255ee39
commit 1149d6018e

View file

@ -182,7 +182,9 @@ module SimpleForm
options[:as] ||= :select
options[:collection] ||= options.fetch(:collection) {
reflection.klass.where(reflection.options[:conditions]).order(reflection.options[:order]).to_a
conditions = reflection.options[:conditions]
conditions = conditions.call if conditions.is_a?(Proc)
reflection.klass.where(conditions).order(reflection.options[:order]).to_a
}
attribute = case reflection.macro