Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6826023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:05:56+00:00 2026-05-26T22:05:56+00:00

I am trying to solve my heroku problem which it seems to have problem

  • 0

I am trying to solve my heroku problem which it seems to have problem of

We’re sorry, but something went wrong.
We’ve been notified about this issue and we’ll take a look at it shortly.

Is there any mistake I have and how to overcome it?
How can I interpret these Heroku logs?

ActionView::Template::Error (PGError: ERROR:  column "microposts.created_at" must appear     in the GROUP BY clause or be used in an aggregate function
2011-11-14T17:33:07+00:00 app[web.1]: : SELECT category FROM "microposts" GROUP BY category ORDER BY microposts.created_at DESC):
2011-11-14T17:33:07+00:00 app[web.1]:     2: <% @categories= Micropost.select("category").group("category")%>
2011-11-14T17:33:07+00:00 app[web.1]:     3: <% unless @categories.nil? %>
2011-11-14T17:33:07+00:00 app[web.1]:     4: 
2011-11-14T17:33:07+00:00 app[web.1]:     5: <ul><% @categories.each do |category| %>
2011-11-14T17:33:07+00:00 app[web.1]:     6: <li><%= link_to category.category, :controller =>"microposts", :category => category.category, :method => 'category_list' %></li>
2011-11-14T17:33:07+00:00 app[web.1]:     7: <% end %>
2011-11-14T17:33:07+00:00 app[web.1]:     8: </ul>

micropost model (New added)

 class Micropost < ActiveRecord::Base
belongs_to :users
default_scope :order => 'microposts.created_at DESC'


attr_accessible :title,:content,:category

validates :user_id, :presence => true
validates :title,    :presence => true,
                     :length => {:maximum =>500}                            
validates :content,  :presence => true,
                     :length => {:maximum =>3000}                           
validates :category, :presence => true
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:05:57+00:00Added an answer on May 26, 2026 at 10:05 pm

    Your immediate problem is that you’re producing invalid SQL for PostgreSQL:

    SELECT category FROM "microposts" GROUP BY category ORDER BY microposts.created_at DESC
    

    Your ORDER BY doesn’t match the rest of your query. You can’t use a column in a grouped query unless that column is also grouped or if the column appears in an aggregate function, that’s what the error message means. The reason is that PostgreSQL won’t know which row’s created_at to use when a group of rows are combined by the GROUP BY clause; some databases will just silently pick a row on their own, PostgreSQL prefers to be strict and wants you to remove the ambiguity yourself.

    Try specifying the order yourself:

    @categories = Micropost.select("category").group("category").order("category")
    

    Another option is to use DISTINCT instead of GROUP BY to avoid duplicates:

    @categories = Micropost.select('DISTINCT(category)')
    

    BTW, you really shouldn’t be doing that sort thing in a view, you might want to move that to your controller.

    Your real problem is that you’re developing on top of one database while deploying on another. I’d recommend that you switch your development environment to PostgreSQL 8.3 (if you’re deploying to a Heroku shared database) or PostgreSQL 9.0 (if you’re deploying to a dedicated database).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to solve this problem for three days now, it's really
I have been trying to solve this problem all day, I googled a lot,
Trying to solve that problem, but no luck for hours... I have var screen1
Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):
In trying to solve the ajax back button problem I have found the Really
I'm trying to solve the 3n+1 problem and I have a for loop that
Trying to solve a very simple problem using mvvm-light, but after days of sifting
Trying to solve a problem of preventing duplicate images to be uploaded. I have
I am trying to solve the following problem but cannot find an elegant solution.
I have been trying to solve this for 2 weeks and I have not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.