- 論壇徽章:
- 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的方法,這個方法是什么時候調用的? |
|