Skip to content

Instantly share code, notes, and snippets.

View KattyaCuevas's full-sized avatar

Kattya Cuevas KattyaCuevas

View GitHub Profile
@jwo
jwo / mysql.database.yml
Last active July 10, 2024 18:15
Sample config/database.yml from Rails. Postgres, MySQL, and SQLite
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
@oelmekki
oelmekki / any_of.rb
Last active December 16, 2015 07:09
class ActiveRecord::Base
def self.any_of( *queries )
queries = queries.map do |query|
query = where( query ) if [ String, Hash ].any? { |type| query.kind_of? type }
query = where( *query ) if query.kind_of?( Array )
query.arel.constraints.reduce( :and )
end
where( queries.reduce( :or ) )
end