Test-driven development can be a little slow going, jumping between your code and your console, and targeting tests by line is prone to error. Use these tools and techniques to streamline your TDD.
Sometime you need to test how your code handles an uploaded file, but you don’t want to upload it in your test. Luckily, there’s an easy way to handle this.
RailsConf offers an opportunity to submit proposals directly related to specific tracks. Learn more about two of these tracks to get inspired and craft successful proposals.
Cropping an animated GIF with
crop will continue to use the original image’s canvas size. This cool trick will ensure the cropped image ends up the correct size.
With the inclusion of Action Cable in Rails 5, we can easily add WebSockets to our Rails applications. This post walks through how to set up Action Cable as a response to an action on an Active Record model.
While looking at a controller today, I came to the conclusion it’s better to use
ActionController:API instead of
ActionController::Metal. Here’s why.
Figuring out why your feature tests are failing can be difficult, especially when setting up the first few tests in the codebase.
When using Ruby on Rails Form Helpers, it could be useful to add an autocomplete feature to fields where users might reuse data. One way to do that is to use Selectize.js to create a dropdown and populate it with data from the user model.
Starting today, Heroku has a new free SSL offering. Use it with Let’s Encrypt for a fully free SSL system.
The Rails 5 upgrade has a few changes that may cause confusion. We look at how to get around the disabling of autoloading and look at the new deprecation warnings.
Months can be difficult to work with when they have a differing number of days. Rails helps out with #month, but you still need to use caution.
There’s a better way to implement business logic, and track events in Rails.
I needed to renew an SSL certificate today, so I used it as an excuse to try Let’s Encrypt for a free certificate for a Rails app hosted on Heroku.
I’ve been working on an application that works to match users together based on a complex set of criteria (read: big slow database query and in-memory processing). The core usage of the application revolves around these user matches, so I want to make sure that either the algorithm will run very fast or can be cached so that it’s not run every time a user visits their matches page.
The most important requirement for our matches is reciprocation. To solve this problem and meet all of the requirements, we can create a bi-directional, self-referential, self-syncing, many-to-many association between users using a
has_many :through association with a join model to keep track of a user’s matches.
We need to make getting up and running with our Rails apps easier. Here’s my attempt.
The pluck method is a performant option to query columns from one or more tables. The ability to pass valid SQL directly makes it all the more handy.
Some tricks to help you fix tests that sometimes fail.
Insert your app’s bootstrapping into CI to ensure that setting up a new developer is one script invocation.
I recently gave a talk covering
pluck, and the PostgreSQL Cursor gem for the West Michigan Ruby Users Group.
Code to copy-paste so you can lazily serialize JSON and maybe even stream it to the client, and an argument for why we shouldn’t have to do any of this.
Some ways to reduce memory usage as you gather records out of your database into Rubyland.
Part one of a four-part series which will show you how to optimize a memory-heavy Rails API action.
Changing Ruby’s garbage collection parameters is the least invasive way to optimize your app’s memory usage.
Flash messages were one of those little features that amazed me when I was first introduced to Rails. Developers often use Rails’ flash to display messages to their users, but messages aren’t the only reason to use flash.
Tips on how we like to organize Gemfiles and keep it clean.
People are under the impression that HABTM relationships are deprecated because of the newer Has Many Through relationship. Both are good, and both have their place, but HABTM is still valid, vibrant, and useful!
Fixtures are great tools that have been sadly overlooked for a long time in the Rails world. Lets start using them again.
Two years ago and 264,309 downloads ago, I wrote the Figaro gem. I had been using the pattern for some time already and was frustrated that something so simple wasn’t already included in Rails. And now, finally, it is! Well… sort of.
After teaching an Advanced Rails class last week, I realized that we use a lot of patterns internally to build great APIs in Rails that many people don’t know about. We didn’t invent most of them, but we use them with great success, so we need to start sharing.
Can you point to a single place in your application and say “here is where we implement our business rules and use cases”, or are your use cases spread out across controllers, models, libs and elsewhere? Do you have fat models, fat controllers, and/or a massive lib directory? Is adding new features quick and easy or painful and time consuming? I have a solution to your pain.
Our new screencast series features narration by Christopher Walken.
One of the things holding us back from developing on Ruby 1.9.3 has been ruby-debug. So after many people suggested we try it, we gave pry a shot. I don’t know why we didn’t before; it is quick, easy, and allows a wide range of Ruby versions.
Using Stripe to take credit cards online.
Symbols in Ruby are confusing to new users.
Swapping out Firefox for Chrome is easier than you think!
There’s a Rails Hackfest this weekend and we are opening our doors to Rails devs who want to participate.
Writing routes that are conditional upon whether a user is logged in is easy with Rails 3 but if you find yourself (as many of us do) stuck with a Rails 2 app, here’s how to achieve the same fancy routes without the latest Rails.
Have you ever noticed that the GitHub homepage is different once you log in? I’m not talking about little changes here and there. It’s a completely different page. I have no idea how GitHub does this but I’ll venture a guess and demonstrate how to achieve the same effect.
Testing with sunspot with cucumber can be tricky since you need to manage the solr process separately. This post introduces a new gem “sunspot_test” and how to easily use it.
After using Bundler for the past few months, I love it. It turns managing project dependencies and deployment into a piece of cake. However after coming across a particular dependency declaration, something clicked in my head that made me like it even more.
In my previous post I mentioned that out of the box Solr breaks up the search indexes on whitespace. This post will outline how you can configure Solr to search within words.
A whole world of rich objects is within your reach with MongoDB.
My list of open source tools that made a big impact on our work this year.
Lots of people have been wondering about SSL after seeing Firesheep in action. Here’s how to get started with Rails.