Skip to main content

ruby

2015

Testing rake tasks
·284 words·2 mins
rake ruby rspec
This post continues our work in Improving our rake tasks with OOP. In this one, we will discuss how to test our rake task; the example will be very straightforward. We will invoke the rake task and expect that some classes receive the correct arguments.
Improving our rake tasks with OOP
·684 words·4 mins
ruby rake
I have been writing some rake tasks for downloading backups, accessing APIs, or automating tedious and repetitive work. Rake tasks are great, but dangerous at the same time. We add so much code to our rake tasks that they become a source of errors.

2014

Self-referential Associations in Rails
·273 words·2 mins
rails ruby associations
When I first heard about this concept, I needed clarification. I was reading Learn Rails by Example by Michael Hart The concept was too complex to understand by then, so I researched.
Lazy Enumerator
·121 words·1 min
ruby
Recently reading some posts about ruby, I found myself with this exciting method called lazy. This method will help us when looping over some objects: Array, Hashes, and Files. If you want to loop through a huge array, and we only want to select the first 20 elements that evaluate our criteria, this is the kind of job for our lazy method.
Delayed job, Heroku and sending an email with attachments
·465 words·3 mins
rails ruby heroku delayed_job
Rails make it extremely easy to send emails. I’m not going to explain how to do it; there are pretty good tutorials around the internet, this one is well explained: Action Mailer Basics.
Rails and select
·210 words·1 min
ruby rails
In a rails project I’m working on, I was trying to select from the database some sales with some conditions. Here is the Sale model: class Sale < ActiveRecord::Base belongs_to :voucher belongs_to :client has_many :line_items, dependent: :destroy has_many :bills end So the goal of the task was to obtain all the Sales where the LineItems has express_checkout set it to true.
Integrate Disqus with Octopress
·393 words·2 mins
ruby octopress
I’m new to Octopress platform for Blogging, but I think it is excellent and straightforward. Creating my first post, I felt so excited, similar to when you discover a new treasure or secret path in my favourite game.
File rename in ruby
·242 words·2 mins
ruby
While doing some exercises in the book Learn to Program by Chris Pine, trying to rename some files I noticed a strange functionality as part of some exercise that was renaming pictures from a folder.