best_in_place with a many to many relationship in rails 4

非 Y 不嫁゛ 提交于 2019-12-06 04:13:25

I think the following code should work:

<%= best_in_place @user, :event_country_ids, as: :select, 
  collection: Country.all.each_with_object({}) { |i, memo| memo[i.id] = i.name }, 
  place_holder: "click here to edit",
  html_attrs: { multiple: true } %>

Assuming you want the user to be able to assign multiple event_countries.

Reference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!