Robert Eshleman

  • Blog

Readable RSpec Tests with Helper Methods

October 17, 2014

I’m a recent graduate of Metis, a 12-week Ruby on Rails course taught by some great folks from thoughtbot. This post is part of a series sharing my experience and some of the things I’ve learned.

I’ve been spending a lot of time recently becoming familiar with Rspec, Capybara, and TDD. Because tests frequently have similar or repeated steps, this has also been a great opportunity to practice DRY-ing up my code.

One particularly effective technique I’ve been using often in my tests is extracting helper methods with descriptive names to make my code easier to read.

Continue reading

Using Postgres Views with Rails

September 18, 2014

I’m a recent graduate of Metis, a 12-week Ruby on Rails course taught by some great folks from thoughtbot. This post is part of a series sharing my experience and some of the things I’ve learned.

Most relational databases support the concept of a view, a pre-defined relation that’s essentially a stored query. You can query a view just like any other database table, but the fields and values in a view are defined based on the query used to create the view.

Views can be used for a number of reasons, most of them related to abstraction. For example, a view could be defined to allow easier querying of a complex join or to filter a relation to include only a subset of data.

In this post, we’ll take a look at using a Postgres view with Rails to encapsulate data in a repeated aggregate query.

Continue reading

Private Class Methods in Ruby

August 22, 2014

This summer, I’m learning Ruby on Rails at Metis, a 12-week class taught by some great folks from thoughtbot. This post is part of a series sharing my experience and some of the things I’m learning.

File this one under, “fool me once, shame on you; fool me twice, write a blog post.”

In Ruby we use the private method to define instance methods that are only accessible from within a class:

Continue reading

Using Rails Namespaces for Admin Actions

August 14, 2014

This summer, I’m learning Ruby on Rails at Metis, a 12-week class taught by some great folks from thoughtbot. This post is part of a series sharing my experience and some of the things I’m learning.

Rails has several strategies to help us separate concerns in our applications. We use separate files and directories for models, views and controllers, for example, and we can nest routes based on how the resources are related to each other.

In addition, Rails permits the use of namespaces to organize our resources and prevent naming conflicts. In this post, we’ll take a look at why this feature is useful by implementing a namespace for admin actions in a sample Craigslist clone Rails app.

Continue reading

Learning a Team-Based Git Workflow

August 8, 2014

This summer, I’m learning Ruby on Rails at Metis, a 12-week class taught by some great folks from thoughtbot. This post is part of a series sharing my experience and some of the things I’m learning.

At Metis this week, we’ve transitioned from learning in a classroom environment to collaborating with a team on our first projects. Among the challenges we’ve encountered, mastering a Git workflow stands out as one of the most useful — but also intimidating — skills to learn.

Continue reading
Next

Copyright © 2014-2022 Robert Eshleman.
Powered by Jekyll with Type Theme.