Skip to content

Instantly share code, notes, and snippets.

fixture_file_upload is a good way to simulate an uploaded file in tests. In Rspec, make sure to include ActionDispatch::TestSupport

Useful Rspec custom matcher to write: with_layout(layout)

assign(:variable, 'value') in your specs

Anonymous controllers in tests for testing filters

Testing nested hashes

@jraines
jraines / docsplit.md
Created June 9, 2011 22:08
Docsplit notes

Dependencies

  • GraphicsMagick
  • poppler-utils
  • open office -- will this work with Open Office on server?
gem 'docsplit'

Extraction

@jraines
jraines / rails31init.md
Created May 24, 2011 17:03
Rails 3.1 with Rspec, Cucumber, Factory Girl, Haml, and Simple Form

Install Rails 3.1 RC

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@jraines
jraines / em-intro.md
Created May 19, 2011 17:43
EventMachine intro

Don't block the reactor loop

Use blocks as callbacks

Use async libraries

EM.start_server('0.0.0.0', 1337, ChatClient)

Instance variables keep state on a per Connection basis

@jraines
jraines / richapps.md
Created May 19, 2011 15:19
Building Rich Apps - RailsConf 11 notes

###If I'm just sending JSON back and forth, why do I need Rails?

Rails is a rich HTTP abstraction, handles a lot for you

Read the HTTP spec

##ActionDispatch

###Middleware

@jraines
jraines / worker-pattern.md
Created May 18, 2011 20:32
Horizontal scaling with the Worker pattern

Note - reference these slides; good diagrams

##High traffic

Problem: Heavy lifting inside the request cycle

  • Bound by slowest API
  • Potential redundant retrieval (popular search term)

The Worker Pattern decouples web request from services required to respond to request

@jraines
jraines / bundler-deploy.md
Created May 18, 2011 19:19
Deploying with bundler - RailsConf 11 notes

####Scope your gems to your app:

bundle install --path vendor/bundle

####Ensure that bundle install has been run locally

(ie, there are no gems in Gemfile that do not match the lockfile

bundle install --frozen

@jraines
jraines / eventmachine.md
Created May 18, 2011 18:52
EventMachine Railsconf notes

Implementation of the Reactor pattern

  • Most web apps are I/O bound, not CPU bound
  • Instead of waiting on a response from the network, use that time to process other requests
  • Handle 5-10k concurrent connections with a single Ruby process
EM.run do 
  EM.start_server '0.0.0.0', 2202, EchoServer
end
@jraines
jraines / searchbox.md
Created May 18, 2011 15:48
Notes on "Enhanching the Search Box" - RailsConf 2011

###Autocomplete

  • the big lebowski
  • Prefix search
  • rails-3-jquery-autocomplete Gem
    • rails g autocomplete
    • javascript_include_tag "autocomplete-rails.js"
    • autocomplete :resource, :title #, :full => true
    • autocomplete_field_tag
  • Not really flexible over multiple models
@jraines
jraines / SASS-notes.md
Created May 18, 2011 15:18
Notes on SASS presentation - RailsConf 2011

Use this format to assign variables:

$error-red: #911

Transformations:

background-color: lighten(red, 10%)

Functions: