Ruby (on Rails) Snippets (19)

7 days ago View more (90 lines)
1
2
3
4
5
require 'memcached'

module ActiveSupport
  module Cache
    class MemcachedStore < Store
7 days ago View more (179 lines)
1
2
3
4
5
module Cacheable
  def self.included(base) #:nodoc:
    super
    base.extend ClassMethods
    base.extend MethodMissing
8 days ago View more (1 line)
1
Test
2 months ago View more (54 lines)
1
2
3
4
5
#!/usr/bin/env ruby

madlib = "Our favorite language is ((gem:a gemstone)). We think ((gem)) is better than ((a gemstone))."
prompts_reg = /\(\([a-z _-]+:[a-z _-]+\)\)/
reg = /\(\([a-z :_-]+\)\)/
2 months ago View more (90 lines)
1
2
3
4
5
require 'memcached'

module ActiveSupport
  module Cache
    class MemcachedStore < Store
2 months ago View more (15 lines)
1
2
3
4
5
# Threadsafe User.current

class ApplicationController < ActionController::Base
 before_filter :current_user_id

2 months ago View more (8 lines)
1
2
3
4
5
# Install memcached 
wget http://download.tangent.org/libmemcached-0.22.tar.gz
tar -xzvf libmemcached-0.22.tar.gz
cd libmemcached-0.22
./configure
3 months ago View more (71 lines)
1
2
3
4
5
# As seen on http://blog.fiveruns.com/2008/9/24/rails-automation-at-slicehost

#    This script will remotely configure your Slicehost VPS with the necessary applications and libraries
#    to serve and monitor a production Ruby on Rails application.  A simple "Hello World" Rails
#    Application is installed and started to confirm the process.
3 months ago View more (24 lines)
1
2
3
4
5
# Nesting
map.resources :team, :has_many => [:players, :articles ], 
              :collections => { :search => :post }

link_to @team.name, team_players_path(@team)
3 months ago View more (42 lines)
1
2
3
4
5
# Namespaced Keyed Flash Messages

# Normal Usage
if @snippet.save
  flash[:notice] = "Good news everyone!"