Learn

How to install Bootstrap 4 in Rails

How to install Bootstrap 4 in Rails

Every day there’s a new library in the spotlight or maybe just a new version of a really popular one like Bootstrap in this case that doesn’t always have a corresponding ruby gem that you can install into your app yet. So what do you do? Do you sit and wait until someone decides to write one for you?

Understanding and extending Rails form helpers

Understanding and extending Rails form helpers

Helpers in rails are meant to clean up view code by allowing you to extract data processing logic from your markup code. By moving the logic out, you get an added benefit, you can test your “view logic” easier. At least that’s the most common use case you’ll see in Rails.

Nested trees with Ruby on Rails

Nested trees with Ruby on Rails

Did you ever needed to get the children’s children of a newsted tree like structure? Well it turns out, in Rails, that stuff is pretty easy to do. You can use the awesome_nested_set gem and you’re all set, everything is right there for you to use.

Decoupling CSS Selectors From Your Tests

Decoupling CSS Selectors From Your Tests

For a long time, I’ve been bothered by the problem of using CSS selectors to target DOM elements in my tests (with Capybara). In this short article, I’m going to try Eduardo Gutierrez’s suggestion of using data attributes for targeting DOM elements instead of CSS selectors.

7 Steps to better Cucumber tests

7 Steps to better Cucumber tests

When you are starting out with rails testing there are so many things you need to learn about and thus it’s very hard to have a clear picture of what goes where and what’s the best way of writing unit tests and view specs and integration tests etc.

The Beginner's Guide to Rails Helpers

The Beginner’s Guide to Rails Helpers

Helpers in Rails are used to extract complex logic out of the view so that you can organize our code better. This article is meant to shed some light over the “How and when to use Rails Helpers”.

Mastering Ruby Blocks in Less Than 5 Minutes

Mastering Ruby Blocks in Less Than 5 Minutes

Blocks are one of the most powerful and often overlooked feature of ruby. There is something about yield that makes blocks very hard to understand at first. I’m going to talk about some of the concepts and provide a few examples so by the end of this post you’ll have a solid understanding of ruby blocks.

How to Use link_to in Rails

How to Use link_to in Rails

Even after 7 years of using Ruby on Rails I still have trouble remembering how to properly use all those options available for the link_to helper. Three out of five times I have to fire up the docs and search for the examples (cause that’s how I like to read the docs).

3 ways of testing private methods in Rails

3 ways of testing private methods in Rails

Here’s a topic that pops up often especially when faced with the common task of testing controllers in Rails. We have some logic inside a private method and we want to test it somehow. And of course, like most things in ruby, there are a few ways to do it which we’ll look at next.

How to test controllers in Rails

How to test controllers in Rails

These days it seems like everyone is looking for faster tests and for good reason since loading the entire Rails framework on every test run makes the process way to slow. I want to address the issue of testing controllers in this article as I find it to be a confusing topic even for some of the more senior rails developers.