【发布时间】:2015-11-20 14:56:08
【问题描述】:
我正在使用 Rails 和简单的表单。我有一个用关联字段显示的集合。对于集合中的每个项目,我希望将鼠标悬停在属于该项目的属性的标题上,即description。
这是我的协会:
<%= f.association :user_roles, collection: @roles, as: :check_boxes, label_method: :name, label: false %>
我想将鼠标悬停在每个角色的描述文本上。在我的脑海中,类似以下的事情应该是可行的:
<%= f.association :user_roles, collection: @roles, wrapper_html: {title: UserRole.where(id: this_current_items_id).first.description}, as: :check_boxes, label_method: :name, label: false %>
或:
<%= f.association :user_roles, collection: @roles, wrapper_html: {title: :description}, as: :check_boxes, label_method: :name, label: false %>
这些显然都不起作用,但在我看来,这样的解决方案应该很容易。我想简单形式的家伙从来没有想过这种情况。
但是,这可能吗?或者,如何获取当前项目的 ID,以便在悬停时显示该项目描述?
PS:我需要的是一个简单的表格hover_method!
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 simple-form