Ever wonder where ruby’s
defined? is defined? Because it looks so like a method, you might end up trying to check out a bunch of places, such as:
BasicObject, or even
Module, but only to find no luck locating it in any of such places. Well, only until you’ve realized it, the answer is pretty simple:
defined? is not a method but an operator or a keyword.
In rails apps among the commonly-used two popular web servers, unicorn serves requests with worker processes, while puma can do it with both process workers and threads. Therefore, switching to puma from unicorn can not only help improve concurrency but also reduce memory usage. Plus, since rails 5.0, the default web server used is puma.
With a gem called activerecord-import, importing a huge amount of records into mysql table becomes an easier task to do, and this post demonstrates how to achieve it.
Upgrading application rails version from
5.1 is easier than doing from 4.2 to 5.0, since it’s only a minor version update. However, there might still be quite a few things to address either from framework changes or due to outdated gems dependency.
RSpec is a popular test framework in ruby.
Rails framework autoloads constants so that in environments like
test, the app does not need to load everything into memory before serving requests. However, autoloading is known to be thread unsafe in rails (at least for versions less than 6), and if you happen to be using threaded servers like
webrick, it’s very easy to step on unexpected issues caused by multiple threads.
Upgrading rails to a new major version can be tricky because there might be many breaking changes from the framework itself or from many gems used in project that will become either deprecated or unsupported. However, it can also go smooth if done in a right procedural way. This post shares the procedure based on my recent hands-on experience in upgrading rails from
126.96.36.199 for our API server. Please be kindly noted that depending on project configuration or dependencies, the upgrading steps might be slightly different for various projects.
Rack is the gem that provides the interface between web frameworks (
ruby on rails,
sinatra) and web servers (
unicorn) in ruby world.
Rake is a Make-like task runner in Ruby. First define a list of tasks in ruby syntax in a
Rakefile and then invoke the task with rake command.