Skip to content

Instantly share code, notes, and snippets.

This is gist.
There are many like it, but this one is mine.
It is my life.
I must master it as I must master my life.
Without me gist is useless.
Without gist, I am useless.
require "rubygems"
require "dm-core"
class Word
include DataMapper::Resource
property :id, Serial
property :text, String
has n, :translations #, :model => 'Word', :foreign_key => [:word_id]
This is gist.
There are many like it, but this one is mine.
It is my life.
I must master it as I must master my life.
Without me gist is useless.
Without gist, I am useless.
module Rack
class AllYourBase
def initialize(app, options = {})
@app = app
@options = options
end
def call(env)
@request = Rack::Request.new(env)
Error
ActiveRecord::StatementInvalid in Admin/dashboardController#show
PGError: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ...comments ON comments.post_id = posts.id ORDER BY comments.c...
^
: SELECT distinct posts.* FROM "posts" INNER JOIN comments ON comments.post_id = posts.id ORDER BY comments.created_at DESC LIMIT 5
Application Trace | Framework Trace | Full Trace
class Post < ActiveRecord::Base
# [...]
named_scope :order_by , lambda { |order| { :order => (order) } }
named_scope :limit , lambda { |*lim| { :limit => (lim.first || DEFAULT_LIMIT) } }
named_scope :published_before, lambda { |*time|
{:conditions => [ "published_at < ?", (time.first || Time.now) ]}}
named_scope :with_comments, {:include=>:comments}
named_scope :remove_duplications, :select => 'distinct posts.*'
==== Error
ActiveRecord::StatementInvalid (PGError: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ...comments ON comments.post_id = posts.id ORDER BY comments.c...
^
: SELECT distinct posts.* FROM "posts" INNER JOIN comments ON comments.post_id = posts.id ORDER BY comments.created_at DESC LIMIT 5):
app/models/comment_activity.rb:18:in `find_recent'
app/controllers/admin/dashboard_controller.rb:4:in `show'
===== Controller