RailsCasts Pro episodes are now free!

Learn more or hide this

Leo Gallucci's Profile

GitHub User: elgalu

Site: http://elgalu.github.io

Comments by Leo Gallucci

Avatar

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.

Avatar

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:

ruby
"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...

Avatar

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(STDIN.read)'

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

Avatar

Using capybara for web scraping

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

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

# 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: https://gist.github.com/zhengjia/428105

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

Avatar

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

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

Rails + Heroku with heroku-config

shell
heroku config:push

Rails + Capistrano with dotenv-capistrano

ruby
require "dotenv/capistrano"

Plain old Ruby apps with dotenv

ruby
require 'dotenv'
Dotenv.load

Rake tasks

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

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

shell
cp .env.example .env