Skip to content

Instantly share code, notes, and snippets.

@alea12
Created September 21, 2013 14:19
Show Gist options
  • Save alea12/6651063 to your computer and use it in GitHub Desktop.
Save alea12/6651063 to your computer and use it in GitHub Desktop.
なんか Rails というか ruby におけるオブジェクトの扱い方を完全に間違えてる気がする
class Post < ActiveRecord::Base
# posts table から、public が 1 なレコードの id 一覧を取得する
def self.public_post_id_list
Array(select('id').where(public:1).order('id desc')).map{|a| a.id.to_i}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment