In this final part we are going to explore blocks, array decomposition, partially applied methods and a few syntax tricks. We'll also study a few known methods to understand how everything is used in real world applications.Read more »
Articles about Ruby
In the first part of this series we talked about positional arguments, but there are more types. In this second part we'll talk about keyword arguments.
Positional and keyword arguments share a lot of characteristics so we'll split this article into similar sections, but there are some key differences we'll touch on in each section.Read more »
Ruby is an object oriented language where everything is an object (even methods are objects of the class Method!), so everything we need to do is done by calling methods on objects. That also means that methods have to provide a lot of flexibility because they are used everywhere.
Ruby provides a lot of options to pass arguments to our methods, so we'll make this topic a series so it's not too long. We'll split the options into different categories and then break down everything with some examples and/or use cases.Read more »
A few months ago I received the task of making the FastRuby.io sitemap refresh automatically after each deploy. That sounds like it would be pretty straightforward if we didn't have one issue (it's never that easy, right?). For the FastRuby blog we created a gem that encapsulates a Jekyll application. The discussion of why do we have a gem for our blog is actually a good topic for a new post. For now, I want to focus on the sitemap task that I had.
Since the blog is a gem, we also need to make sure that whatever tool we use to generate the sitemap covers new blog posts.
In this article I'll show you my journey to figure out how to make everything work together.Read more »
"Jekyll is a simple, extendable, static site generator. You give it text written in your favorite markup language and it churns through layouts to create a static website. Throughout that process you can tweak how you want the site URLs to look, what data gets displayed in the layout, and more."Read more »
Everyone has had the experience of working on a gnarly, difficult to understand code-base. The sort of code base that makes you hate your job. Often it comes down to poor design, but code conventions also play a large part in whether you wake up dreading your job in the morning. The overall design (choice of design patterns and how modules and classes are organized and factored) is the long range, big picture strategy of how an application will be made. Code conventions, by contrast, come down to the choices you make about which constructs of a language you use, which you don't, and when.Read more »
After reading introductory primers and watching instructional videos for beginners learning Ruby, I needed a program that would allow me to test out Ruby concepts for myself. I began practicing Ruby Koans, a testing-based program that runs through a variety of Ruby concepts in a trial and error fashion.Read more »
Be it for performance or for readability, sometimes it's nice to be able to try out something new quickly without going through a pull request + deployment process. This is possible by modifying the $LOAD_PATH Ruby global variable and requiring the gem manually.Read more »
.............................................................................................unknown OID 353414: failed to recognize type of '<field>'. It will be treated as String ...........................................................................................................................................
This Rails app uses a PostgreSQL database. After some Googling, it turns out that this is a warning from PostgreSQL. When the database doesn't recognize the type to use for a column, it casts to string by default.Read more »
When writing tests for services, you may sometimes want to use mock objects instead of real objects. In case you're using ActiveRecord and real objects, your tests may hit the database and slow down your suite. The latest release of the rspec-mocks library bundled with RSpec 3 includes at least three different ways to implement a mock object.
Let's discuss some of the differences between a
double and an
instance_double. First, the
 pry(main)> require 'rspec/mocks/standalone' => true  pry(main)> user_spy = spy(User) => #<Double User>  pry(main)> spy.whatever_method => #<Double (anonymous)>
A few times in the past I've had to interact with IMAP via Ruby, and wrapping your head around its API is not so easy. Not only is the IMAP API a bit obscure and cryptic, but Ruby's IMAP documentation is not so great either.
Searching the internet for examples doesn't yield too many results, so I'll try to write down some of the things I've learned. The examples I'll show use Gmail as the target IMAP server.Read more »
A few weeks ago, I found an interesting project called
Bumbler. If your project uses Bundler,
Bumbler shows you your project's largest dependencies.
When you find yourself staring at the screen after running
bundle exec rails c, you may want to give this tool a try.
Sessions provide you a nice little data storage feature where the application does not need to get the information directly from the database. So you do not have to persist data in your database and can easily store info about the user on the fly. This is a nice way to enhance the user experience on your page.
Let's say that you want to show some users a new fancy sign up form and the rest the old form. If you store the version of the sign up form in a session variable, you don't need to persist this info in your database.Read more »
Maybe in the past you stumbled over the two different approaches to setup your test variables. One way is the more programmatical approach by using instance variables, usually initialized in a
We have been using Slack at OmbuLabs for a while now after switching from HipChat, and haven't looked back. It looks and feels much better than any other available platform of its kind. Slack provides WebHooks, which you can use to post messages to your team's channels.Read more »
Read more »
default_scope is a method provided by ActiveRecord, which allows you to set
a default scope (as its name implies) for all operations done on a given model.
It can be useful for allowing soft-deletion in your models, by having a
deleted_on column on your model and setting the default scope to
Enumerable#select is the chosen method to obtain elements from an
Array for a given block. Without thinking twice, we may be doing more work than
necessary by not taking advantage of another method from the Enumerable module,