Skip to main content

Posts

2014

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.
Restore PostgreSQL backup within Heroku
·138 words·1 min
heroku postgresql
Recently I was playing around with my local database in my Rails project deployed using Heroku. Eventually, I screwed up and had to delete all the data. I use rake db: reset and rake db:create`, but how would I populate the data again?
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 Postgresql Error ORDER clause
·135 words·1 min
rails postgresql
While working on a rails project recently, I stepped on an error that said: PG::Error: ERROR: column “number” must appear in the GROUP BY clause or be used in an aggregate function`,
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.