【发布时间】:2014-05-18 20:11:20
【问题描述】:
我有一个帮手为 Ransack 添加新的搜索字段:
def link_to_add_fields(name, f, type)
new_object = f.object.send "build_#{type}"
id = "new_#{type}"
fields = f.send("#{type}_fields", new_object, child_index: id) do |builder|
render(type.to_s + "_fields", f: builder)
end
link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
end
让我来:
<%= link_to_add_fields "Add Condition", f, :condition %>
但我需要
<%= link_to_add_fields f, :condition do %>
Add Condition
<% end %>
这又给了我这个错误:
ArgumentError
wrong number of arguments (2 for 3)
我完全不知道如何实现这一点。那里有好心人吗?
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4 helper