u16suzuの blog

日々学んだことのメモブログです。

2016-08-24から1日間の記事一覧

学習のためRailsのコードリーディングをした時のmemo

rails と rspec scopeのマージは、以下のようにかくと、paramsの条件分岐が綺麗に書ける. scope = User.where( id: user.id ) scope = scope.where( 'created_at >= ?', params[:date_from].to_date ) if params[:date_from].present? scope = scope.where( …