Skip to content

Instantly share code, notes, and snippets.

# [] - Eqauls to
# ^ - Not equals to
# =~ - LIKE
# >, >=, <, <= works as expected
#
# Examples :
#
# Item.where(:colour['Red'], :quanity > 10, :price <= 200)
# Post.where(:comments_count >= 1, :taggings_count < 5)
# User.where(:country ^ 'US') # Non american users
def handle_remember_cookie!(new_cookie_flag)
return unless @current_user
case
when valid_remember_cookie?
@current_user.refresh_token # keeping same expiry date
when new_cookie_flag
@current_user.remember_me
else
@current_user.forget_me
http://github.com/lifo/fast_context
module SetupOnce
def self.included(base)
base.class_eval do
attr_accessor :copy_ivars_blocks, :copy_ivars_binding, :copy_ivar_names
alias_method_chain :run_current_setup_blocks, :copy_ivars
alias_method_chain :initialize, :copy_ivars
alias_method_chain :build, :copy_ivars
end
end
class User
has_many :items
end
class Items
belongs_to :user
validates_presence_of :user_id
end
Factory.define(:user) do |u|
[lifo@null rock (master)]$ ruby extconf.rb && make
[lifo@null rock (master)]$ ruby run.rb
commit 3caaafd3518ece4fe62b8aca8382ac70b3235be0
Author: Pratik Naik <pratiknaik@gmail.com>
Date: Tue Aug 11 19:18:39 2009 +0100
Add more tests for rendering partials inside views
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index 7f30ae8..09ff70d 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
def eq?(x, y)
x = x.dup
y = y.dup
deleted = []
x.each_with_index do |e, i|
if y.include?(e)
deleted << e
y.delete_at(y.index(e))
$ sudo gem update rack
Updating installed gems
Updating crack
Successfully installed crack-0.1.3
Gems updated: crack
Installing ri documentation for crack-0.1.3...
Installing RDoc documentation for crack-0.1.3...
require 'erb'
require 'ostruct'
module FuckingHelpers
def last
"from helper"
end
end
vars = OpenStruct.new :first => 'Mislav'