The singleton class is rarely used in practice to modify the behavior of specific objects. Read on to learn a few practical applications that might prove useful in your code.
The singleton class, also referred to as the metaclass or the eigenclass. What is it exactly? In this post we dive into Ruby’s internals to demistify this aspect of the language.
One idea I’ve always appreciated about the routing approach in Rails is path helpers, which are automatically generated from route definitions.
Some advantages of using path helpers are:
It’s easier to manage and understand state in Vuex when it is split between different modules. However, the default approach has some shortcomings that make modules cumbersome to use.
Read on to find out how to leverage all the goodness in Vuex using a more natural and convenient API, making your app easier to reason about and refactor.
Would you like to prevent problems and regressions? Refactor with confidence? Save development time? Make any area of the app accessible to other developers?
Read on to find out how a team that documents their work is on a better path to achieve all the above.
One of the nicest bits of syntax sugar in Ruby are keywords.
In this short post we will explore the keyword operator in Ruby, and a few things you should have in mind when first getting started with it.
Today I’d like to share a simple but very useful practice for managing Ruby and JS code under version control.
In our team, we always use trailing…
BetterSettings is a settings-management library for Ruby apps, which was designed in response to certain issues we faced when using settingslogic (one of the most popular libraries to manage settings in Rails applications).
In this post we’l…
When providing services to different companies or customers with the same software, such as enterprise or white-label applications, it’s not unusual that each customer uses different terminology for certain concepts within the application.
…Mongoid provides support for MongoDB’s Aggregation Framework, but writing raw queries can be confusing and is extremely verbose:
Product.collection.aggregate [
{ '$match' => { 'country' => 'US' } },…
Like most object-oriented languages, Ruby has both instance and class variables. The syntax is @name
for instance variables, and @@name
for class variables.
Let’s look at a simple…
In this post we take a look at effective ways to reduce the amount of watchers in our AngularJS application and improve the performance of our app.
AngularJS might not be hip anymore, but it’s still a useful framework to create interactive web apps. In this post we will take a brief tour through Angular’s internals: watchers and the digest cycle.
Cucumber steps often involve asserting a condition or the opposite of it. For example:
Then(/^I should see a "(.*?)" comment$/) do |message|
expect(page).to have_css('li.comment', text: message)
end…
jquery-rails
powers links and forms in Rails: it’s what makes remote: true
work, allowing any link to make an AJAX request unobtrusively.
rails-ajax_redirect
is an extension to this unobtrus…
Anko is a library for Android development in Kotlin. The library provides helper methods that take advantage of Kotlin’s extension functions as a way to reduce the amount of boilerplate the And…
A language helps to shape the libraries that are written on it. This can have unexpected side-effects when using these libraries from a different language.
In the frontend this has become increasingly more common because of all the availab…
Bash is the default terminal for most Unix distributions, so it’s very appealing to get the best out of it. If you enjoy customizing your setup, you might want to try something like zsh instead, which comes with similar functionality ou…
Blocks are a very unique part of Ruby’s syntax, but sometimes it can be tedious to write a block to perform a simple method call. An extremely common idiom in Ruby uses symbols to specify the method that should be called, but.. how does it work?
Mongoid is not designed for extensibility; if you need to modify its behaviour in a slight way, you will probably have no choice but to monkey-patch it.
A while ago I was working on a feature that required displaying information from several mongodb collections. The performance was pretty bad, since for each item being displayed it was necessary to traverse nested and polymorphic associations to get the rest of the data.…
One of the downsides of using an ORM is that it abstracts the queries in a way that it’s difficult to understand which queries are being performed; it’s harder to notice inefficient queries, since we didn’t actually write them!
A performance issue that is very common when using ORMs is the N+1…
By default, Mongoid will use single-collection inheritance when extending a Ruby class, by storing a _type
attribute in every document in the collection that contains the concrete class name,…
Recently I’ve been digging into the #lesscode movement, which proposes that software tools exist to solve real problems—a piece of code that doesn’t solve a problem is just waste. It also implies t…