Rails用数组查询

时间:2016-07-15 19:16:32

标签: ruby-on-rails arrays ruby-on-rails-4 filter

所以在我的控制器中我创建了一个页面,其中只显示了group_pages(脚手架),其中数组@group_post_users包含当前用户,所以:

def my_group
  @group_pages = GroupPage.all
  @group_pages.each do |group_page|    
    @group_page_users = group_page.page_users.split(',')
    @group_page_users.push(group_page.user.email)

    @mg_users = User.find_by_email(@group_page_users)
    @gg_users = User.where(:email => @group_page_users)

    group_page.super_uses = @gg_users
    @g_pages = GroupPage.where(:super_uses => @selected_posts.map(&:id))

  end
end

现在我在@group_page_users中有一个group_page的用户数组,我只想在@group_page中显示包含当前用户的组页

基本上我想要这样的东西:

@g_pages = GroupPage.where(:super_uses => current_user.email)

0 个答案:

没有答案