Counting with select

jmarceli Dec 20, 2017

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').cou...

PAGER DUTY & EXCEPTION NOTIFIER PLUGINS FOR RAILS

rubyonrailsdevelopment Aug 10, 2017

RAILS EXCEPTION NOTIFIER

The Exception Notifier plugin provides a mailer object and a default set of templates for sending email notifications when errors occur in a Rails application. It is basically a monitoring tool, which keeps on watching the application and whenever it finds any error, it tri...

Faker Gem: Fake Data Generation in Ruby

rubyonrailsdevelopment Jun 28, 2017

Gems are libraries in Rails that generally enable you to write the application code faster and thereby making a great product in far lesser time. Usually, whenever we start developing any application, there comes a point when we need data which we can use to see how the application will behave while...

Sort Integers

newdark Jan 16, 2017

ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]

==== Sort From Greatest to Smallest

>> [1, 2, 3, 4].sort { |a, z| z <=> a }
=> [4, 3, 2, 1]

Clarifying the confusing example

lazylester Jan 5, 2017

since exit is a keyword in Ruby, the example may be confusing. The following example might be less so: module Foo begin # this raises an error b/c baz is not defined here alias_method :other_baz, :baz rescue NameError =>e puts e end

def baz
  put...

Rails caching with dalli gem

rubyonrailsdevelopment Dec 15, 2016

Dalli is a high performance pure Ruby client for accessing memcached servers. It works with memcached 1.4+ only, as it uses the newer binary protocol.

Memcache Memcached is a quick in-memory protest reserving framework that can make Rails run much quicker with not very many changes. Memcached is an...

Code Refactoring Gem – Flay

rubyonrailsdevelopment Dec 2, 2016

Flay examines code for structural likenesses. Differences in literal values, variable, class, method names, whitespace, programming style, braces vs do/end, props versus do/end, and so forth are all overlooked,making this absolutely rad. It’s fit for recognizing both correct and close matches, and d...