This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [] - 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://github.com/lifo/fast_context |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
has_many :items | |
end | |
class Items | |
belongs_to :user | |
validates_presence_of :user_id | |
end | |
Factory.define(:user) do |u| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[lifo@null rock (master)]$ ruby extconf.rb && make | |
[lifo@null rock (master)]$ ruby run.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 3caaafd3518ece4fe62b8aca8382ac70b3235be0 | |
Author: Pratik Naik <[email protected]> | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'erb' | |
require 'ostruct' | |
module FuckingHelpers | |
def last | |
"from helper" | |
end | |
end | |
vars = OpenStruct.new :first => 'Mislav' |