railsがんばる子

Ruby on Railsがんばる子です。胡蝶蘭のECサイトを運営しています。

2015-04-07から1日間の記事一覧

has_one throughは、includesで代替可能

has_one throughは、includesで代替可能 has_one :fuga has_one :hoge, through: :fuga default_scope -> { includes(:hoge).references(:hoge).where(hoge: {id: xxx} } has_one :fuga default_scope -> { includes(fuga: :hoge).references(:hoge).where(h…