RSSAmplifier

Blog

Kalina Tech

Stories, tutorials and tips for software engineers

blog.kalina.techRSS feed ↗11 posts

Latest posts

Nested API parameter validation in Rails with ActiveModel::Validations

You can find the final code example integrated to a Rails app here . The Story In an earlier project we had affiliate partners with a deep desire to interact with our system in an automated fashion. So I created new API endpoints for them to send leads to our system. Then we started testing the integration together and everything was rosy until we met some hard-to-debug errors because of the…

End-to-end testing for API only Ruby on Rails apps with Cucumber syntax

In an earlier project, we had good test coverage with only unit tests produced following TDD practices. But despite our careful work, one unfortunate day, we broke a core functionanlity in production, even though our test suite was fully green. It turned out that the units under test encountered difficulties when working together outside the safe and isolated testing environment. This experience…

Debugging MySQL lock errors in Ruby on Rails

New week, new bug to hunt down! A day after our last deployment, we encountered a new type of error that started occurring randomly. Certain SQL update queries were failing with the following error: ActiveRecord : :StatementInvalid : Mysql2 : :Error : Lock wait timeout exceeded ; try restarting transaction : UPDATE users SET . . . At first glance, it seemed like something locked our DB longer than…

Upgrading Ruby on Rails from 3.2 to 4.2

We recently upgraded our 8-year-old legacy FinTech application from Ruby on Rails version 3.2 to 4.2. Here are the key lessons learned and challenges we encountered during the process. From 3.2 to 4.0 The upgrade process was already underway when I joined the company and took over. I continued with a few improvements, following this simplified workflow: Listen to podcasts about how others did it.…

Data too long for column error after upgrading to Rails 4

After upgrading Rails 3.2 to 4.0 we had an interesting and yet unexpected new error: ActiveRecord::StatementInvalid: Mysql2::Error: Data too long for column 'target_column'... It turned out that MySQL strict mode was not enabled in our Rails 3 project. And as a consequence MySQL silently truncated the content of all string or text type columns in case if they didn’t fit in the size of the given…

Git the way I use it

And here comes the ultimate Git article … naw, it is only my modest collection of hacks, workflows and tips. Branch naming schema < prefix > / < ticket-id > - < concise-description > Prefixes I like to use fix --> smaller fix hotfix --> needs to be deployed ASAP bug --> hunting down bugs feature --> new functionality pre-rails4 --> changes to release before upgrading to Rails 4 Ticket ID It can be…

Debugging weird HTTP POST error in Ruby

The story As I presented in a previous article : I discovered a weird error without any backtrace or clue except an error message: Error at Server . After some research I managed to unearth the hiding exception and the missing backtrace. The exception pointed to some HTTP POST requests we sent to a microservice. To make it even more entertaining it only happened in production from time to time and…

Updated table in the where clause in MySQL

TL;DR; A user can have many loans. There are many users and loans in our MySQL DB. The task is to update loans.checked_at with the corresponding users.checked_at in case of the first loan record of each user. The story We had the following simplified MySQL database structure at work. The original business plan was to perform a certain check for every new loan once. But for some reason, the…

Exception without backtrace in Ruby

The other day I saw a funky error in our error log: Error at Server . Unfortunately this was it, no backtrace, no exception class, nothing just a timestamp. It proved to be difficult to identify the root of it without any more info. So I looked up the error message in the code base and found this little snippet: rescue StandardError Rollbar . error ( 'Error at Server' , extra_params : { . . . } )…

Double-checking if a method is unused in Ruby

Have you ever met a method in the codebase that seemed very much unused, but you were not 100% sure and didn’t dare to remove it? In this tutorial we are gonna build a tool that sends a notification if a marked method gets invoked. This helps us to double-check if the method in question is indeed unused before removing it. A real life example for Ruby’s Prepend The final product in action GitHub…

Building online presence in the tech world

One good way to get in the community, to attract future employers or to get a promotion is to improve our online presence. It is generally true in every field, but today let’s look into the booming software industry with a slight emphasis on job hunting. First and foremost I need to state that I don’t want to look overly confident, or big headed. I share my modest story and experience so far. Some…