Notes posted by jmarceli

RSS feed
December 20, 2017
0 thanks

Counting with select

If you try to write

Model.select('field_one', 'field_two AS something').count

it will fail (at least for Rails 5.0) with the message PG::SyntaxError: ERROR: syntax error at or near “AS”. In order to fix that issue, you should write

Model.select('field_one', 'field_two AS something').count(:all)
March 17, 2016 - (>= v4.2.1)
0 thanks

Default values

By default :on_update and :on_delete have :restrict value.