PostgreSQL, Rails + Heroku, Column must appear in "group by" -


I am receiving this error when I put my app on Heroes:

  GET started "/ archive / transecact / search? Utf 8 =% e 2% 9c% 93 and search% 5Btagged_with% 5D = village and amp = command = search" for 98.201.5 9.6 2011-03-27 17 : 02: 12 -0700 ActionView :: Template :: Error (PGError: Error: The column should appear in the "photos.custom_title" GROUP BY section or should be used in an aggregate job: SELECT "photos". * "Photos" "Tag" from INNER "" "" "id" = "tagging" "." "" "" Name "IN ('g And ') "(" photo ")" tag "" tag_id ".collection_id = 1) GROUP BY photos.id LIMIT 20 OFFSET 0): 17: 18: - @bodyclass =' ​​dark '1: #search_view .photo_tiles 20: = render: partial = & gt; collection / photo / alt_tiles',: archive = & gt; @photo :: as in =>: photo app / visualization / archive / search.html .humble : 20: These `_app_views_collections_search_html_haml__2343730670144375006_16241280__2249843891577483539 '  

I saw this same question (,).

The problem is that nothing in this view is asking for the custom_title feature, nor is I performing a query with the "group_by" section.

Trigger error that is partial here:

  - ((photo_counter + 1)% 5 == 0)? @ Class = 'last': @ class = '' .photo {: class = & gt; @ Class} .alt_tile = link_to (image_tag (photo.file.url (: tile)), collection_photo_path (collection, photo) ,: class => 'img_container'). Location = photo.location (: min) .tags = Photo.tag_array.join ('|')   

Here is the archive #search action that this error Has been raised:

  def search @ circuit_tolbar = true @collection = store.fund (param [: id]) @search = @ collection.photos.search (param [[search]) @ Photo = @ search Page (Param [: Page]). (20) End   

So it seems that this is a plugin issue? I am using Cabanadi for Meta Search and Pageri for search functionality. Does anyone have any ideas or suggestions that are due to this particular reason and how can I decide it?

- Edit -

OK, I think the real problem:

Using Meta Search with my keyword tag model, Created method that looks like this:

  def self.tagged_with (string) array = string.split ','). Map {| S | | S.lstrip} joins (: tags) .where ('tags.name' = & gt; array) .group ('photos.id') end   

Now, I've given a lot Was helped in making this method - as I mentioned before the total SQL Fool.

This method works on SQLite, but does not occur on PostgreSQL because whenever any are included in a search, this "group" problem.

So, it looks like I'm part of my photo model in "Columns" or the postgre will be broken. Need to insert each column.

For many reasons:

  1. My photo model is very complex and has a ton field.
  2. My app is still in development and photo model is any other.
  3. Every time a person forgets to add a column to the group statement on the search logic, I do not want to break my code if I touch the photo model in the future.

    So, how can someone understand how to rewrite this method so that he can not break PostgreSQL - ideally, so that I can get all the solutions related to this model Do not include the list of areas, or at least manually listed list?

    Therefore, it has come to know that I am using my "<"> tag With the "selection" method in place of "group" I can solve this problem. def self.tagged_with (string) array = string.split (','). Map {| S | S.lstrip} ('separate photo. *'). Joins (: tags) .where ('tags.name' => array) end

    The problem is resolved! See this article as a great explanation, why is it a better idea anyway. (Sorry, the web site was later deleted and I did not remember what he said.) Also, please reply to the Spinoff question that resolves my problem.

Comments