Exploring Object-Relational Mapping in Ruby

As for homework this week, I was given the task to create a Sinatra app with each Object-relational mapping (ORM) we learned in class: Sequel, ActiveRecord and DataMapper. I built these simple applications that gave a name, age, color and description to rabbits. Link to the repository here.

In this blog post, I am going to talk about my experience using all three ORMs and state my favorite one.
Continue reading “Exploring Object-Relational Mapping in Ruby”

Use Them, Blockhead! – Learning to Use Ruby Blocks

Blocks are sort of mystical to me. I know very little about the magic that happens under their hood. To aid this lack of knowledge, I decided to write a blog post on blocks hoping that by writing about them I will acquire some knowhow.

As I understand it, blocks are pieces of code that are wrapped by either curly brackets

 array.each{ |element| #some logic here# }

or between a “do” and “end” example:

array.each do |element|
#some logic here#

Inside either the curly bracket and the do-end boundaries of the block you write what you want your block to do. So far so good.
Continue reading “Use Them, Blockhead! – Learning to Use Ruby Blocks”

Recursive Dancing

Friday night, class was over and we, the students, were celebrating the end of a successful week by playing games and dancing. I was dancing to my heart’s content when I looked at the white board. It had the following code:

def fibo_finder(num)
  if num < 2
    fibo_finder(num-1) + fibo_finder(num-2)

It was the solution a ruby problem we had earlier in that day. It required us to find the nth number of the fibonacci sequence.
Continue reading “Recursive Dancing”

Troubleshooting Heroku Deployment Errors

I was at my wit’s end. For one hour or two, it indeed felt longer, I was trying to deploy a Sinatra web application that I created this past week week at the Flatiron school to Heroku. Something was definitely amiss because Heroku kept telling me:

! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to ...

I tried to remove and add the heroku repo again and again to no avail. I tried to close terminal and restart it but nothing. What did I do to you, Herokuuuuu???? I felt like weeping, anime-style.
Continue reading “Troubleshooting Heroku Deployment Errors”