Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Leo Gallucci's Profile

GitHub User: elgalu


Comments by Leo Gallucci


Agree with that eager loading. More on that: #22 Eager Loading (revised)

I think the intention of the screencast was to show how to use Dalli and not to focus on how to improve that example webpage.


The cache keys need to be unique in order to fetch its value later on.

So category_id is different for each category.

Think of the array [:category, category_id, :name] as syntactic sugar for what ends up being a cache key string.
For example:

"category/3/name" # the key that caches the category's name for the category_id 3
"category/4/name" # the key that caches the category's name for the category_id 4
"category/5/name" # the key that caches the category's name for the category_id 5

and so on...


By checking the docs Action Mailer - Receiving Emails you'll see that no receivers are provided, i.e. nor POP3 or Maildir built-in support.

You need to somehow trigger the ActionMailer recieve method every time an email is received, e.g.

rails runner 'UserMailer.receive('

Mailman solves that for you but ActionMailer doesn't, you would need to write your own Maildir Guard plugin and/or a POP3 polling daemon to call UserMailer.receive


Using capybara for web scraping

gem 'capybara', '~> 2.1'
gem 'capybara-mechanize', '~> 1.1'
require 'capybara'
require 'capybara/mechanize'

Capybara.configure do |config|
  config.run_server = false
  config.default_driver = :mechanize = "" # to avoid this error: ArgumentError: mechanize requires a rack application, but none was given
  config.app_host = ""

# Including Capybara::DSL in the global scope is not recommended but for the sake of this example:
include Capybara::DSL

visit "/session/new"
fill_in "password", :with => "secret"
click_button("Sign in")
# etc.. capybara cheat sheet:

You can replace capybara-mechanize with any other headless capybara driver, e.g. poltergeist or capybara-webkit


Foreman + dotenv + dotenv-rails + heroku-config

My preferred configuration management tools.
Using them always with your .env file either on development or production, in heorku or VPS, with rake or capistrano, on Rails or any app.

Rails 3 / 4 with dotenv-rails

gem 'dotenv-rails', :groups => [:development, :test]

Rails + Heroku with heroku-config

heroku config:push

Rails + Capistrano with dotenv-capistrano

require "dotenv/capistrano"

Plain old Ruby apps with dotenv

require 'dotenv'

Rake tasks

require 'dotenv/tasks'
task :mytask => :dotenv do ... end

Note: do not commit your .env file but commit the example

cp .env.example .env