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:
parent
1da255ee39
commit
1149d6018e
1 changed files with 3 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue