0
更改内容我有两个型号:国家和用户与选择菜单
country.rb
class Country < ActiveRecord::Base
has_many :users
end
user.rb
class User < ActiveRecord::Base
belongs_to :country
end
所有用户(来自所有国家)显示在users/index.html.erb页面上。
users_controller.rb
def index
@users = User.all
end
用户/ index.html.erb
<%= collection_select(:user, :country_id, Country.all, :id, :country_name) %>
<%= render @users %>
还有与用户/ index.html.erb所有国家都选择菜单。
我该如何做到以下几点:当某人选择特定的国家时,将只显示来自选定国家的用户?