Codebeerstartups

Codebeerstartups

Every Dog has one Blog


Featured

Private Class Methds, Ruby

Private Class Methods In Ruby

Posted on .

A quick tip to how to difine a class method as private method, I have seen lot of people doing it wrong way. Lets take a quick look on how to define a private instance method in ruby

class Dog
  def poop
    "Going outside, and will poop :)"
  end

  private

  def bark
    puts 'woof woof'
  end
end
Featured

Image optimizations, lazy-loading

Lazy Loading of Images in Rails

Posted on .

Recently I joined a company thats Thrillophilia a tours and activities company in India, and where I need to solve a problem of lazy loading of images, cause the site is image heavy. I came across lot of lazy loading javascript plugins, but finally came to know about Layzr plugin simple, lightweight and works like charm.

Featured

ruby-on-rails, caching, scaling-rails

Scaling Ruby on Rails by Caching your database queries

Posted on .

Its pretty good to use active-record in ruby on rails, relationships, find_by methods, where queries everything makes your life much more simpler as a developer but sooner or later your application becomes slow. At that time you need to work on optimizations. There are lot of work around for optimizations and one of them in caching the queries. The company I work for is StudyPad and we have a product ie splashmath and that has over 9 millions users using it across multiple platforms. The amount of traffic that we get is pretty huge and caching one of the thing that helped us to solve out scaling problems. Here is quick idea to cache your queries in memcache.

Featured

ruby-on-rails

Spliting Seed files into multiple file in Ruby on Rails

Posted on .

Last month I joined a new job after a break of almost 4 months. You can checkout the product and there we had a small problem that our seed file was growing very fast. So we did a small thing to maintain our seed file. Here is a small tip if you are having a massive seed file and its pretty easy to implement.

Featured

migrations ruby-on-rails

Irreversible Migrations in Ruby on Rails

Posted on .

In Rails 2 in migrations there were only 2 methods: up and down. They are called on running migrations up and down respectively with rake tasks rake db:migrate and rake db:rollback.

Rails 3 produced us great method change which allowed us to write there code which creates a table and drops the table automatically on rolling migration back. But unfortunately there was a problem - you didn’t have opportunity to say “don’t run this peace of code on down but run this only on up”. So the solution was just to use old syntax. Since Rails 4 has released there is a feature to fix this situation.