Codebeerstartups

Codebeerstartups

Every Dog has one Blog


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.

Featured

devise linkedin facebook google github twitter

Social Login integration with all the popular social networks in ruby on rails

Posted on .

I have seen lot of people writting pretty messy code to integrate social logins in rails or get confused to integrate multiple social logins in rails. In order to help them I have written a small application having integrations with Twitter + Facebook + Linkedin + Google + Github.

Here is the demo and here is the source code

I am using devise in this application. Few things to note in this:

  1. There are two models in this application a user model and an authorizations model and a user has_many authorizations.
  2. User can link to multiple social account from edit profile
  3. Once social accounts are linked, user can login from any connected social network.
  4. If user tries to create an account with a different social network while in loggedout state. System maps it to the same account if that email address exists in the database else it will create a new account.
  5. Twitter don’t provide email address of the user, nothing I can do about it.
  6. There are lot of other commented out gems in the Gemfile. Those are the gems that I use a lot in my various projects. I will strongly suggest you to checkout those gems.
Featured

ruby-on-rails bundler

Parallel gem installing using Bundler

Posted on .

My bundler is running

No more waiting time. Bundler supports faster gem install as it adds support for parallel installation. You can pass in –jobs=SIZE (or -jSIZE) as a parameter to bundle install