Should I use Ruby on Rails in 2021?

An article, posted about 2 years ago filed in rails, ruby, ruby on rails, laravel, symfony, php, python, django, flask, hanami, comparison, enterprise & trust.

I'm still a big fan of Ruby on Rails. No other framework has ever made me as productive. And it is no a secret that it makes quite some other product companies very successful. Think of Shopify, Github, Basecamp, Hey, and others.

But if you'd look at at the list of most popular languages, the top 10 doesn't feature ruby anymore.

In their 2020 survey on most popular technologies, StackOverflow writes:

> Additionally, Ruby, once in the top 10 of this list as recently as 2017, has declined, being surpassed by newer, trendier technologies such as Go and Kotlin.

Also if you look at Google trends, ruby has always been negligible when compared to Python or PHP or Javascript, [the trend is downward for the ruby package manager](https://trends.google.nl/trends/explor…

Continue reading...

Global variables in Rails

An article, posted more than 4 years ago filed in global, variables, rails, ruby & ruby on rails.

A quick note, because I was using the wrong search terms. If you want to share e.g. the current user of an app with a model you can now (since Rails 5.2) use a model inheriting from ActiveSupport::CurrentAttributes. Before you were required to pass this current user explicitly or find another way to access state.

Note that this can either be a good thing or a bad thing (tl;dr: thread-local global state makes apps unpredictable)

And even the docs warn against abusing this feature. Powerful tools can come with dangerous consequences :) Global variables are immensely powerful. Use with care. I'm not even sure if I'm going down this path…

Continue reading...

Prometheus for slow stats

An article, posted more than 4 years ago filed in development, engineering, cluster, management, devops, rails, ruby on rails, ruby, logging & monitoring.

Prometheus is a statistics collecting tool that originated from SoundCloud. Designed to be used in high performance environments, it is build to be blazingly fast. Hence, the client typically is expected to be blazingly fast as well, gathering and presenting data within nanoseconds. For Ruby on Rails applications however this has lead to an unresolved issue with the Prometheus ruby-client when the same application is forked (typical for Puma, Passenger and other popular ruby-servers). The Prometheus client collects data within its own fork before serving it to the exporter endpoint. This can or cannot be a problem. When you measuring response times, running averages from a random fork may be good enough. However, when you're also counting data over time you're having separate counters in …

Continue reading...

JavaScript & Rails: a `webpacker` evaluation

An article, posted more than 5 years ago filed in javascript, ruby, rails, ruby on rails, programming, es2015, coffeescript, gem & assets.

Webpacker is still opt-in for new Rails projects. But this might change. The JavaScript ecosystem is moving fast and new JavaScript frameworks are pushing customer’s expectations to higher levels. To use these frameworks with your Rails app, you had a few options:

  • Include the JavaScript manually; which requires you to manually copy the files in place
  • Use a gem-wrapper to to install the JavaScript library; but this required quite some maintenance on the Gem-author’s side.
  • Try to mangle npm or yarn into the asset pipeline yourself
  • Use Rails Assets (an automagic Gem-wrapper)

A small praise for Rails Assets

I have been using rails-assets.org the past few years to keep my JavaScript dependencies up to date. It thought it was smart solution; instead of requiring individual developers to maintain Gem-wrappers, Gem wrappers are created on the fly by RailsAssets.org. It was smart and light weight on the developers side and worked perfectly with the Rails' Asset p…

Continue reading...

Eat your own dogfood

An article, posted more than 6 years ago filed in social_linker, gem, ruby, ruby on rails & update.

Just a small note that I've made some improvements to my SocialLinker-gem lately and while I've been using it on a few sites already, I wasn't using it on my very own blog. Today I found some time to change exactly that: you've got to eat your own dog food. If you want to have a taste of it: murb/social_linker (if you're a ruby-dev) or just click the share icons below :)

Image CC-licensed BY: Sh4rp_i

Continue reading...

ActionCable and authentication with Devise (2/2)

An article, posted almost 7 years ago filed in authentication, ActionCable, devise, rails, ruby on rails, ruby, websockets & communication.

This is a short follow up on the previous article in which the ActionCable basics were explained. We can now add some level of authentication. Authentication is a bit harder than simply registering some before_action’s, but it is perfectly doable, especially if you've survived the previous tutorial.

From the official Action Cable guide we can simply reuse the full connection.rb template:

module ApplicationCable
  class Connection < ActionCable::Connection::Base
    identified_by :current_user
 
    def connect
      self.current_user = find_verified_user
    end
 
    protected
      def find_verified_user
        if current_user = User.find_by(id: cookies.signed[:user_id])
          current_...

Continue reading...

Getting started with Rails ActionCable (1/2)

An article, posted almost 7 years ago filed in ActionCable, rails, ruby, ruby on rails, programming, tutorial, websockets & webapp.

As the lead developer at HeerlijkZoeken.nl I wanted to try the new Rails ActionCable technology for a new feature: shopping lists. The idea is that you can walk in a store or on a market, mark an ingredient as checked when you add it to your (physical) basket and continue shopping. ActionCable can make the experience nicer because it, based on WebSockets, allows for real time notifying other viewers and editors of the same shopping list. No more shouting around in the supermarket: I’ve got the milk! Sure, nothing essential, but I needed an excuse ;)

(Note that we recently migrated from Rails 4, so not everything was in place in our app, just ignore the bits Rails already made for you; everything has been tested with Rails 5.0.0.1)

Getting the basics right

To start: You need a web server that can open multiple threads, so if you’re still using Webrick in development (which can’t rece…

Continue reading...

Mijn werk: QKunst Collectiebeheer

An article, posted about 7 years ago filed in ruby on rails, mijn werk, portfolio, zelfstandig, zzp, excel, qkunst & kunst.

murb bestaat 6 jaar. Een goed moment om terug te blikken op de opdrachten van weleer. Deze keer: QKunst Collectiebeheer

Wat is het?

Dit is wat QKunst zelf schrijft:

> QKunst is gespecialiseerd in het inventariseren van grote bedrijfscollecties. Om deze inventarisaties nog soepeler te laten verlopen, ontwikkelden wij QKunst Collectiebeheer, een web applicatie voor collectiebeheer. Hiermee worden grote hoeveelheden informatie over een collectie toegankelijk en kunnen we uitgebreide rapportages uitdraaien.

Het probleem

QKunst had te maken met meerdere zaken die verbeterd konden worden ten opzichte van hun oude tool: Excel.

  • De foto’s van kunstwerken waren lastig te beheren,
  • Rapportages waren moeilijk te maken,
  • Versiebeheer vroeg te veel aandacht.

Gaandeweg ontonden er nieuwe ideeën waarmee de dienstverlening verder verbeterd kon worden: communica…

Continue reading...

Mijn werk: “AxlBase”.

An article, posted more than 7 years ago filed in ruby on rails, gem, mijn werk, portfolio, ING, zelfstandig, zzp & excel.

LinkedIn confronteerde me onlangs nog met het feit: murb bestaat alweer 6 jaar. Een goed moment om verder te gaan met terugblikken op de opdrachten van weleer.

De belangrijkste opdrachtgever in mijn beginjaren was de ING bank. Een belangrijk product dat ik in de begintijd aldaar heb gebouwd is een database op basis van Excel-bestanden (iets dat ik ooit nog wil(de) uitrollen als 'AxlBase'). Zoals ik eerder al schreef, soms moet je een bestaande werkwijze omarmen. Wat is het precies en van waaruit is het ontstaan?

Wat is het?

Een database op basis van Excel-bestanden. Niet echt in technische zin (achterliggend is het een traditionele database), maar wel in de praktische zin. Excel is hét bestandsformaat van de gewone kantoormedewerker voor gestructureerde data. Het wordt veelvuldig gebruikt in allerlei projecten. AxlBase is in staat verschillende Excel-bestanden per o.a….

Continue reading...

Tag descriptor

PortableRails

An article, posted more than 7 years ago filed in portablerails, ruby, rails, ruby on rails & windows.

Making Ruby + Rails portable for the Windows platform (in other words, work without command line unfriendly installers). Updates below, code and readme on Github

Continue reading...

Learning from failures: off-line support in a rails-app

An article, posted more than 7 years ago filed in rails, react, ruby, frontend, backend, offline, online, app, nodejs, ruby on rails, formdata, forms & cache.

As a web-developer you typically assume that your users are always using your app on-line. When asked a year ago to start developing an app for the art-consulting firm QKunst I was, however, specifically asked for a tool that had to work in bunkers. Bunkers where having a solid internet connection was typically the exception. No problem, I read about HTML5 and offline app-cache: I thought I could fix that. More about that soon.

How I face a challenge

When faced a (technical) challenge I typically search for the easiest way out: what would be the slightest change I’d have to make to my battle tested set-up to accommodate for the new challenging feature. In my case this battle tested set-up starts of with the Ruby on Rails stack, which builds on techniques that align well with how I believe the web should work too. RESTful (proper HTTP-messaging and URLs), semantic, CURL-able. And all graceful…

Continue reading...

Mijn werk: Concordia weekoverzicht

An article, posted more than 7 years ago filed in kijkwijzer, rubygems, gem, ruby, rails, ruby on rails, web, ontwikkeling, portfolio, svg & mijn werk.

murb bestaat inmiddels een aantal jaar, daarom lijkt het me leuk om de komende blogposts een aantal mooie resultaten te delen. Als eerste in de rij: Het Concordia Weekoverzicht.

Wat is het?

Concordia, een culturele instelling in Enschede, brengt iedere week een weekoverzicht op A5-formaat uit. De weekoverzicht tool die ik voor hen heb gebouwd maakt het mogelijk deze zonder veel moeite wekelijks uit te draaien.

Het probleem

Tot zomer 2015 was het maken van het weekoverzicht een repetitieve handmatige invuloefening met dure en ingewikkelde Adobe software, terwijl de meeste gegevens keurig waren opgeslagen in hun ticketsysteem en de kijkwijzer-database. Het voordeel van de Adobe-pakketten was weliswaar oneindige mogelijkheden qua opmaak, maar in de praktijk was het eindproduct telkens vrijwel hetzelfde. Ondertussen koste het handmatig opmaken dus relatief veel tijd en kunde.

De oplossing

Het volledig automatisch genereren van e…

Continue reading...

Ruby on Rails is fast

An article, posted almost 8 years ago filed in speed, performance, rails, cache, caching, ruby on rails & ruby.

Of course, this title is obviously too blunt. Still, when I see applications being developed on supposedly fast languages such as Java that perform terribly slow it makes me wonder.

Today I had to fix an issue with the slowness of an overview page inside a product I wrote using Rails. I don't like pagination (it's a workaround), but I wasn't expecting pages with over 700 items. The page with items stored in a traditional database was performing somewhat slow: it took about 6 seconds to load. The fix however took me less than half an hour (including searching the docs) from idea to execution and deployment on production (writing this post took me longer):

  old view code to render the item

Passing the item itself to the cache ensures that the cache gets invalidated when the item is updated. The page load it is still kinda heavy, with 500ms of load time, but this is acceptable for its size.

Features like this make Rails not only a super fast way to realise…

Continue reading...

Een nieuwe website

An article, posted about 13 years ago filed in nieuw, tags, tagging, website, murbcms, murb.nl, feedback, contact, ruby, rails, ruby on rails, techiek & cms.

Al enige tijd worstel ik met de beste manier om mijn site up to date te houden. Voorheen was mijn site in PHP geschreven, en hoewel het werkte schreef ik er al snel erg lelijke code in.Wanneer je zelf ook graag wilt blijven experimenteren betekend de keuze voor een techniek soms ook het beperken van de vrijheid tot experiment, of verlies van eenheid. Toch heb ik in het afgelopen jaar ontdekt dat het Ruby on Rails framework mij voldoende vrijheid biedt zonder dat ik daar allemaal rotzooi door ga schrijven. En daarom kondig ik dus nu vandaag officieel aan (in de loop van gisteren drong hij door tot de domeinnaamservers): de nieuwe murb.nl website! De nieuwe website is een stuk eenvoudiger, met vooral de nadruk op de artikelen uit de blog. Oude artikelen worden verder automatisch bij de reeds geschreven artikelen gezocht op basis van de labels die ik ieder artikel mee geef. En dat lijkt mij voorlopig een grote verbetering tot de oude, en voorlopig voldoende. Feedback laten we in verban…

Continue reading...

murb blog