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
1 changed files with 3 additions and 1 deletions

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