Blog - Page 7 of 8


Course three week one red green refactor
Posted on

Red-green-refactor is an important concept in TDD when you are using tests to drive your code and I’ll use an example to demonstrate how this works. First I start off with a series of descriptions about what I want my code to do. As an example, I have a todo list that has a name and description and I want to write a method that checks if my object only has a name defined. So my initial test setup would be:

Read more
Course three week one github flow
Posted on

GitHub Flow is a workflow guideline for how to work with GitHub and revolves around the idea of deploying regularly to GitHub. This ensures that it is very difficult, if not impossible, to introduce a large number of significant bugs. Additionally it enables me to quickly address issues of all kinds.

Read more
Course three week one testing
Posted on

When talking about testing there are three main techniques to talk about:

Read more
Keep your controllers skinny
Posted on

You’ll hear it lots, fat models/skinny controllers but I was working on a project recently where my controller code was putting on a bit of weight!

Read more
Course two week four final project
Posted on

Building my own application from scratch has been an amazing experience and there’s no way I’d have progressed this fast without the guys from Tealeaf Academy and a local developer I’ve been working with.

Read more
Two factor authentication with twilio
Posted on

In order to do this I will need phone and pin columns added to the users table with a migration. The logic for authentication will be as follows:

Read more
Course two week four part 1
Posted on

Using ajax in rails is similar to how I used method: 'post' for the vote up/down links in order to generate a form on the fly. In this case, using remote: true generates html with a date-remote call. Javascript in rails is looking for that data-remote call and then attaches itself to the element and converts the given link to an ajax call. An example using my code is helpful to explain:

Read more
Extract common code into gem
Posted on

If I had another project that I wanted to add the functionality of voting to then I would be better making a Gem. To begin with I need to install gemcutter. Next I have to make sure I exit my current project folder because the Gem is a completely separate project. Then create a new project called voteable-gem and then it needs a gem specification file which I call voteable.gemspec and it will look as follows:

Read more
Extract common model code to modules
Posted on

In a previous post I wrote a post about how to do this and this post goes through some more ways to achieve the same result in a slightly more succint way. In order to use a module in this case I have to define a path in rails in which to find the module. I need to go to application.rb and add in this line of code:

Read more
Dry model code
Posted on

I had a case in my postit application where I needed to add voting for both comments and posts. This required some code in my models for Post and Comment to count the votes:

Read more