Tutorials

work with Gems – how to choose

Ruby provides a variety of Gems for every requirement and new developers get confused when choosing the between Gems. So I’ll share my personal guidelines for choosing a Gem: 1 – Check if the Gem is maintained:  You can verify if the author mentions in the documentation that this gem is not actively maintained for example Test Benchmark Gem, so in…

Continue Reading
Tutorials

Rails use webhooks in development

When integrating a service provider to your Rails application like payment or mailing, it’s common to face the need of using Webhooks to get a notification about specific events. So how to use webhooks locally? I have used Ngrok for many applications, it’s easy to use and provide an incredible web interface to inspect incoming webhooks. So let’s get started: After…

Continue Reading
Tutorials

Rails routing outside views and controllers

We use Rails routing helpers in views and controllers but sometimes we need to generate a link from a service class or background job. To get started, let’s assume that we have a post resources which provide us with this path helper:

We add the following simple service class:

To check the link generation, we can use Rails…

Continue Reading
Tutorials

Customize Kaminari Pagination

Kaminari is a popular pagination gem for Rails application and provides a decent default template to get started. In this tutorial, we will customize Kaminari template and allow to change dynamically the limit per page. We will use the following mock-up: To get started, follow the steps below:

So we start by editing the app/views/kaminari/_paginator.html.erb partial:

Next, to…

Continue Reading