Tag: best in place

best_in_place在rails 4中有多对多的关系

我已经制作了一个github回购,你可以在这里找到这个问题。 我有3个型号: class User { where(user_countries: {:event => true}) }, :through => :user_countries, :source => :country has_many :research_countries, -> { where(user_countries: {:research => true}) }, :through => :user_countries :source => :country end class UserCountry < ActiveRecord::Base belongs_to :country belongs_to :user end class Country < ActiveRecord::Base # … end 因此用户应该能够选择event_countries和research_countries。 这是我的用户控制器(没什么复杂的): class UsersController [:id, :name]) end […]