Spread article on communities
While spreading an article to communities you are part of, the search crashes when you have the sub_organizations plugin activated. The problem happens in this method:
# app/controllers/my_profile/cms_controller.rb
def search_communities_to_publish
scope = user.memberships.distinct(false).group("profiles.id")
render :text => find_by_contents(:profiles, environment, scope, params['q'], {:page => 1}, {:fields => ['name']})[:results].map {|community| {:id => community.id, :name => community.name} }.to_json
end
The code .distinct(false).group("profiles.id")
was introduced by commit 19ffa2d9 and altered by 4c3699b7 to avoid another crash that was happening with pg_search plugin.
So, with this code the method does not work with sub_organizations plugin enabled (it might have some relation with pg_search being enabled as well, did not test it) and without it, the method does not work with pg_search plugin enabled.
We need to find the proper way to solve this problem.