Skip to content

Instantly share code, notes, and snippets.

Pratik lifo

View GitHub Profile
View lifo.rb
class Lifo < ActionView::Template::Handler
include ActionView::Template::Handlers::Compilable
def compile(template)
ActionView::Template.register_template_handler :lifo, Lifo
lifo /
Created Aug 10, 2011 — forked from tobym/redis_pubsub_demo.rb
Redis PubSub demo with EventMachine (chat service)
require './redis_pubsub_demo'
routes = do
# thin --timeout 0 -V start
run routes
View gist:556759
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index e7e5f26..61cac59 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -6,7 +6,7 @@ module ActiveRecord
merged_relation = clone
return merged_relation unless r
- ((Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS) - [:joins, :where]).each do |method|
+ ((Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS) - [:joins, :where, :order]).each do |method|
View gist:551772
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index fb42ccb..c110810 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -209,6 +209,12 @@ class BaseTest < ActiveSupport::TestCase
assert_equal "New Subject!", email.subject
+ test "translations are scoped properly" do
+ I18n.backend.store_translations('en', :base_mailer => {:email_with_translations => {:greet_user => "Hello %{name}!"}})
View twiscoket.rb
require 'cramp/controller'
require 'cramp/model'
require 'twitter'
module Twisocket
class Socket < Cramp::Controller::Websocket
before_start :set_twitter
# Probably cramp should fire all the timer methods before scheduling them via EM periodic timers
on_start :check_tweets
View Gemfile
gem 'cramp'
gem 'erubis', '2.6.5'
gem 'usher', "0.6.0"
View websock_action.rb
# Requires Cramp 0.8+
require 'rubygems'
require 'usher'
require 'cramp/controller'
Cramp::Controller::Websocket.backend = :thin
class WebsockAction < Cramp::Controller::Websocket
periodic_timer :send_hello_world, :every => 2
on_data :received_data
View gist:268677
[lifo@null rails (master)]$ gem bundle -u
Calculating dependencies...
Cloning git repository at: git://
Updating source:
Downloading abstract-1.0.0.gem
Downloading columnize-0.3.1.gem
Downloading erubis-2.6.5.gem
Downloading i18n-0.3.3.gem
Downloading linecache-0.43.gem
Downloading mail-1.5.1.gem
View gist:268137
diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb
index af6f1bc..016d7b3 100644
--- a/actionmailer/test/abstract_unit.rb
+++ b/actionmailer/test/abstract_unit.rb
@@ -1,6 +1,8 @@
require File.expand_path('../../../vendor/gems/environment', __FILE__)
rescue LoadError
+ $stderr.puts "Running Rails tests requires Bundler. Please 'gem install bundler' and run 'gem bundle' from the Rails checkout path."
+ exit!
View gist:267160
diff --git a/railties/lib/rails/generators/rails/app/templates/config/boot.rb b/railties/lib/rails/generators/rails/app/templates/config/boot.rb
index 6de1725..0240289 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/boot.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/boot.rb
@@ -6,11 +6,18 @@ if File.exist?("#{environment}.rb")
# Use 2.x style vendor/rails and RubyGems
vendor_rails = File.expand_path('../../vendor/rails', __FILE__)
- if File.exist?(vendor_rails)
- Dir["#{vendor_rails}/*/lib"].each { |path| $:.unshift(path) }
You can’t perform that action at this time.