2014-04-02から1日間の記事一覧
ActiveRecordのhas_manyとかbelongs_toとかのAssociationはブロックを渡してメソッドを追加することができます。 class User has_many :blogs do # ステータスがopenのものを取得する def open where(status: 'open') end end end こんな感じで、ブロックの…
ActiveRecordのhas_manyとかbelongs_toとかのAssociationはブロックを渡してメソッドを追加することができます。 class User has_many :blogs do # ステータスがopenのものを取得する def open where(status: 'open') end end end こんな感じで、ブロックの…