Systems | Development | Analytics | API | Testing

Ruby

How to Fix Ruby Bundle Install Errors

A bundle install command in Ruby is used to install all of a project's dependencies. But occasionally, this command could falter and issue an error. Numerous variables might be to blame for this issue, and fixing it might prove challenging. In this post, we’ll go through some of the typical reasons for bundle install errors in Ruby along with solutions.

How to Handle ActiveRecord:: RecordNotFound in Ruby

ActiveRecord::RecordNotFound in Ruby is an error that occurs when an application is unable to find a record in the database that corresponds to the provided parameters. ActiveRecord is a Ruby gem that is used to interact with databases in a Rails application. It provides an object-relational mapping (ORM) layer that allows us to work with database records as if they were Ruby objects.

Calling Ruby Methods in C: Avoid Memory Leaks

Memory leaks are a pain for gem users. They are hard to track and can lead to expensive infrastructure costs. Memory leaks within a C extension are even worse. You'll see a lot of tools and articles about finding leaks in Ruby. However, you don't have the same access to internals in C. A naive usage of rb_funcall can cause memory leaks: it's much better to use rb_protect instead. So, if you are a C extension writer, please read on for the sake of developers who will use your gem. Let's get started!

How to Handle the Unpermitted Parameters Error in Ruby

The ActionController::UnpermittedParameters error occurs when a parameter that has been passed is not permitted in a create, an update, or a user-defined action. In older versions of Rails, information about the unpermitted keys was provided in the logs only when an unpermitted parameter was found in a request. This did not provide enough information for the developers to understand which controller and action received the unpermitted parameters.

Runtime Errors in Ruby

Exceptions are unintended events that take place when a program is being executed or during its runtime causing disruptions to the program's overall logic. In Ruby, a program is enclosed between the begin and end blocks and a rescue block is used to tell what types of exceptions are to be handled. When no class is specified, by default, a RuntimeError is raised by Kernel#raise.

How to Parse Arguments in Your Ruby C Extension

Ruby is a wonderful language, made for humans first and machines second. It is easy to read and write. There are plenty of ways to write anything, and you can often guess its standard library by typing the name of the method you would have chosen yourself. Because of this, Ruby's arguments are very flexible, which lets us express our APIs very clearly. But this comes with a drawback: Ruby is quite hard to parse for C extension developers!

A First Look at Hanami 2 for Ruby

As of today (06/12/2022), Hanami 2.0.1 has been released. Read more about the enhancements, bug fixes and gems in release 2.0.1. Hanami 2 was released on 22 November, concluding four years of work on this version. It brings a breath of fresh air into Ruby's web development community. Version 2.0 is not just an incremental upgrade. One could say it's a project written anew, with bright ideas from version one rebuilt on top of a solid dry-rb libraries ecosystem.

How to Resolve NameError: Uninitialized Constant in Ruby

A NameError is raised when a referenced variable or a constant, such as a module, a class, or a constant variable, isn't defined or is invalid. The Uninitialized Constant error is a variation of the NameError exception class and has several reasons to occur. When this error occurs, several class names appear in place of Something.