Using Rails Resolver Api

Implement Rails Variants in Rails 3.1

Yesterday at work we decided that we need to improve our user experience in web mobile. So we decided that it was time to create a different view for each action. Lately in Rails 4 there is this really cool feature called Variants really neat one if you ask me.

»

Decorator Pattern

Last night I was reading some blogs about ruby patterns, for me is sometimes difficult to understand the use of this kind of patterns, mostly because in my work we just throw thousand of lines of code, and deal with a lot of legacy code from other person who contribute to our projects. I currently work for comparason website in Spain Kelisto Lately there is one projects that is architecture is strongly inheritance, so there are many classes that inherited from a parent class.

»

Set up a simple deployment system

Before deploy in production is always recommended to test everything first, probably you have a Test suit for test your application, but you never know want is going to happen when you deploy all changes to production. What people usually do is create a staging environment, that copies the production environment.

»

Enumerator::Lazy

Recently reading the some posts about ruby I found myself with this interesting method call lazy. This method will help us when looping over some objects: Array, Hashes, Files ……. If you want to loop though an array that is huge, an we only want to select the first 20 element that evaluate our criteria, this is the kind of job for our lazy method.

»

Inverse_of ActiveRecord::Base

While reading the documentation of ActiveRecord::Associations, there are many useful methods, that I didn´t know about it. But one came to me as quite useful, inverse_of. This method allow us to work with associations that haven`t been save yet, so it will work with the memory. This will optimise our object loading.

I will so you with some example.

Class Post < ActiveRecord::Base
  has_many :comments, inverse_of :post
end

Class Comment < ActiveRecord::Base
  belongs_to :post, inverse_of :comments
end

»