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