- 论坛徽章:
- 0
|
在nested_attributes.rb有一段没有理解
Ruby代码- existing_records = if association.loaded?
- association.to_a
- else
- attribute_ids = attributes_collection.map { |a| a['id'] || a[:id] }.compact
- attribute_ids.present? ? association.all(:conditions => {association.primary_key => attribute_ids}) : [ ]
- end
复制代码 这里的为什么会有else情况存在,而且如果是else情况的我觉得整个代码就有问题了,得到的不是期望的结果。
同样这个文件里有REJECT_ALL_BLANK_PROC = proc { |attributes| attributes.all? { |_, value| value.blank? } }
这里的下划线_是什么意思?
第三个问题就是active_support中有一个Concern的类,里面有个方法叫append_features的方法,这个方法是什么时候调用的? |
|