Lessons learned from true, false and nil objects in ruby

Every expression in Ruby evaluates to an object and every object has a boolean value. The boolean values are always the same instance of the TrueClass and FalseClass classes and will therefore always have the same id. Most objects in Ruby will have a boolean value of true. Only two objects have a boolean value of false, Read More

Calling expire_fragment within rails console

Today i want to expire a fragment cache in haml view: -cache(‘taxonomy’) do So I enter in rails c production, but I found Rails.cache.exists?(‘taxonomy’) returned false. expire_fragment doesn’t exist in ActionController::Caching::Sweeper. It can be found in ActionController::Base. The sweeper class uses method_missing to call the method from a controller instance. ActionController::Base.new.expire_fragment(‘taxonomy’, options = nil)  That’s why everything was fine when I Read More

Our life around REPL – Read–Eval–Print Loop

Whenever I see my niece so comfortable with iPhone, Mac, Advance Toys; I usually wonder almost similar feeling our parents must have pondered about us. But what is the biggest disadvantage of being part of GEN X. What? We have best things in the world but the irony is that we don’t enjoy or embrace Read More

Magical ‘If..then..else’ conditional statement

I believe whole programming world stands on couple of pillars and ‘if..then..else’ (ITE) statement is one of those. Everyone programmer and non-programmer understands ITE conditional statement for sure.  A typical if..then..else.. statement in Ruby: if 1 == 2    puts “inside if statement” else    puts “inside else statement” end 1.9.3p385  > inside else statement Another Read More

1 2 3 4