Skip to content

Instantly share code, notes, and snippets.


Tomas Mattia tmattia

View GitHub Profile
troy / oneline_detailed_logging.rb
Created Aug 10, 2012
One-line detailed logging for Rails 3 (ActiveSupport::Notifications) and later
View oneline_detailed_logging.rb
# Outputs this at warn log level:
# GET /path 200 OK BlahController#action HTML 938.2 (DB 11.8, View 719.7) {params} {optional params from flash[:log]}
# Save as config/initializers/oneline_detailed_logging.rb. Consider
# decreasing the log level from "info" to "warn" (in production.rb) so
# the one-line log message replaces the standard request logs.
# override process_action to add 2 things to the payload:
# - remote IP
View email_validator.rb
require 'mail'
class EmailValidator < ActiveModel::EachValidator
attr_reader :record, :attribute, :value, :email, :tree
def validate_each(record, attribute, value)
@record, @attribute, @value = record, attribute, value
@email =
@tree = email.__send__(:tree)
View capybara cheat sheet
=Clicking links and buttons=
click_link('Link Text')
click('Link Text') # Click either a link or a button
click('Button Value')