我有一个与组关联的用户模型。关系如下
class User < ActiveRecord:;Base
has_many :groups
end
class Group < ActiveRecord::Base
belongs_to :user
scope :user_groups, lambda { where(arel_table(:user_id).eq(@current_user.id) }
end
class ApplicationController < ActionController::Base
def current_user
@current_user ||= User.find(session['entity.user']) if session['entity.user']
end
end
我想在组索引页面中的 select_tag 中过滤 current_user 组。
如何做到这一点?