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 »
Articles about Ruby
Today we are happy to announce the launch of our new microsite: Gemfile.lock Audit Tool - a tool created to allow users to check their Gemfile.lock for vulnerabilities in a quick and secure manner.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,