Heroku를 사용하려고하고 있으며 분명히 Postgresql은 집계 함수에 대해 SQL보다 훨씬 엄격합니다. 내가 Heroku를 밀고있을 때 아래에 오류가 표시됩니다.Group by 절에 테이블 열 추가하기 - Ruby on Rails - Postgresql
On another question 나는 내가 단지 내 그룹 by 절에 열을 추가해야한다고 말한 몇 가지 지침을 받았는데 어떻게해야할지 모르겠다. 아래의 전체 오류 및 PostsControll # 색인을 참조하십시오. 가 PostsController
def index
@tag_counts = Tag.count(:group => :tag_name,
:order => 'count_all DESC', :limit => 20)
conditions, joins = {}, :votes
@ugtag_counts = Ugtag.count(:group => :ugctag_name,
:order => 'count_all DESC', :limit => 20)
conditions, joins = {}, :votes
@vote_counts = Vote.count(:group => :post_title,
:order => 'count_all DESC', :limit => 20)
conditions, joins = {}, :votes
unless(params[:tag_name] || "").empty?
conditions = ["tags.tag_name = ? ", params[:tag_name]]
joins = [:tags, :votes]
end
@posts=Post.paginate(
:select => "posts.*, count(*) as vote_total",
:joins => joins,
:conditions=> conditions,
:group => "votes.post_id",
:order => "created_at DESC",
:page => params[:page], :per_page => 5)
@popular_posts=Post.paginate(
:select => "posts.*, count(*) as vote_total",
:joins => joins,
:conditions=> conditions,
:group => "votes.post_id",
:order => "vote_total DESC",
:page => params[:page], :per_page => 3)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @posts }
format.json { render :json => @posts }
format.atom
end
end
그랬습니다. 정말 감사합니다. 다음 호를 별도의 질문으로 게시하려고합니다. – bgadoci
저는 항상 그룹화 된 열을 나열하기 위해 간단한 문자열을 사용했습니다. –