我正在使用 rails 3.2.11 并尝试将对象从视图传递到自定义助手中,但我不明白为什么会这样:
- @data = { name: "Add Skus", f: f, container: "skus", association: :skus, child_association: :images, options: @sku_options }
= link_to_add_fields @data
但这不是:
= link_to_add_fields { name: "Add Skus", f: f, container: "skus", association: :skus, child_association: :images, options: @sku_options }
我得到错误:syntax error, unexpected ':', expecting '}'
辅助方法:
def link_to_add_fields(data)
STDOUT << "name: " + data[:name].to_s + " :: "
STDOUT << "f.object: " + data[:f].object.to_s + " :: "
STDOUT << "association: " + data[:association].to_s + " :: "
STDOUT << "container: " + data[:container].to_s + " :: "
if data[:child_association]
STDOUT << "child_association: " + data[:child_association].to_s + " :: "
end
end