The Ruby and Rails community linklog
Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!
Submit a post
Post Preview
Note: Only the first pargraph is shown on the front page and overly long paragraphs may be broken up.
How to Tell the Difference Between a Default and a Provided Value for Optional Argume
It is sometimes required for the methods with optional arguments to be able to differentiate between its default value and the value passed from the caller. Passing nil might initially sound like a good idea since it represents “nothingness”. However, it might turn out that nil is a legit value and there might be cases where it is desirable for the caller to pass nil. In such a case, we cannot use it as a default value if we want to implement a special logic for the case of not providing that value. [more inside]
Not-so-private constants in Ruby
Sometimes intuition cheats us. That was a case for me with defining private constants in Ruby. Putting them within private block is not enough to achieve the desired effect. https://frontdeveloper.pl/2019/01/not-so-private-constants-in-ruby/?utm_source=rubyflow.com
Playing with Ruby object model: prototypal inheritance
The article shows how to implement something resembling prototypal inheritance. While the end result shouldn’t be used in production, I think it’s an excellent opportunity to learn or systematize certain concepts of the Ruby object model. [more inside]
Programming Crypto Blockchain Contracts (in Ruby) Step-by-Step Guide / Book
Hello, I’ve started a new (free online) step-by-step guide / booklet titled “Programming Crypto Blockchain Contracts (with Ruby) Step-by-Step Book / Guide Let’s Start with P@nzi & Pyr@mid Schemes. Run Your Own Lotteries, G@mbling C@sinos and more on the Blockchain World Computer…”. The first chapter is online with ready-to-run contract scripts in ruby. Don’t Miss the Investment of a Lifetime! May the Brave be Rewared with Riches! Cheers. Prost.
Managing ActionCable Easily
Stimulus.js can be used to setup and tear down connection very easily, just by using the controller’s life cycle and changes to the page. https://johnbeatty.co/2018/12/14/grabbing-actioncable-with-stimulus-js/
42 performance tips for Ruby on Rails
I listed 42 of my favorite performance tips for Ruby on Rails. [more inside]
How ActionCable broke Puma
A short, slightly technical, review of why ActionCable and Puma conflict and why AnyCable or iodine should be used: https://medium.com/@plezi_io/how-actioncable-broke-puma-fcfeceac33b0
Eileen Uchitelle on Getting into Programming, Joining the Rails Core Team, and more
In this episode, Eileen Uchitelle joins Chris Oliver and Jason Charnes to share her journey into programming, how she began contributing to Rails (and subsequently joining the Rails Core Team), and other fun facts/stories around software development. [more inside]
How to Protect Individual Resources with Passwords
Hello! I’d like to share a simple technique for password-protecting individual resources in Rails apps: https://www.gregnavis.com/articles/how-to-protect-individual-resources-with-passwords.html
Data Structures From Scratch (ebook)
A brisk introduction to essential, advanced, and persistent data structures using the Ruby programming language. [more inside]
Ruby's p vs puts Method
The puts method in ruby is very popular all over the internet it’s generally used by ruby programmers for debugging purposes and to output the value of certain variables so we can see what’s goin on in our system. However puts can sometimes lead you astray because of how it converts everything into a string. See how p is different from puts
Enumerate through paginated REST API resources
When working with a JSON API that exposes a list of resources we typically are in presence of paginated results. Today we enable a client library to efficiently enumerate through resources while hiding the complexity of pagination https://hspazio.github.io/2019/rest-client-enumerator/
Chain of responsibility pattern in Ruby on Rails
While we were working on a project we stumbled upon some legacy code that consists of huge ‘if else’ statements. In this post we’ll show you how we refactored it using the Chain of responsibility pattern. Chain of responsibility pattern in Ruby on Rails
Who takes out your trash?
Rain Leander, Technical Program Manager for OpenStack at Red Hat, and Sanne Kalkman, software engineer, on Red Hat Linux and Ruby, and garbage collection respectively: https://www.blog.phusion.nl/2019/01/24/who-takes-out-your-trash/
How to increase app performance by 5-20% (by optimizing rendering time)
https://github.com/igorkasyanchuk/embed_view crazy idea how to improve performance in your Rails application (if you using ERB, but maybe similar could be implemented for slim/haml/etc). [more inside]
ActiveStorage variants are persisting original image EXIF metadata
Imagine you are using Rails 5.2 ActiveStorage. Now you upload an image, render it with app.url_for my_model.image.variant(resize: '400x300') and discover that it’s rotated 90 deg to you would normally expect. You copy paste the link to the image to the browser and discover the image is rotated correctly. How is that possible? [more inside]
Backport support for embedded ERB in Slim views
https://github.com/igorkasyanchuk/slim_erb_backport for developers who are using Slim templates with embedded ERB. [more inside]
First explorations of GitHub's Actions
With the help of a friendly Hubber we set out to automate the workflow of releasing a Ruby gem, based off of the GitHub Action for npm: https://blog.phusion.nl/2019/01/23/first-explorations-of-githubs-actions/
Popularizing your Ruby gem
Once you’ve published your own ruby gem, learn what to do next to get the most out of it. Promote your ruby gem and engage with the developers in the Ruby community [more inside]
How to neatly organise assets in a Rails app
Rails comes packed with a lot of useful conventions. However, it doesn’t say much about how we should organise our front end assets. Here is a way in which we can leverage the same conventions we use to organise our controllers and views to have a neatly organised assets directory. [more inside]
Here to stay - Analyzing RubyGems stats for 2018
What’s up with Ruby? With all the ups and downs in 2018, is it dead or alive? Here at Infinum, we’ve done our research and compiled some stats so check it out. You’re welcome.