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.
RSpec Mocks and Stubs in Plain English
One of the most common questions I see from beginners to Rails testing is what mocks and stubs are and when to use them. https://www.codewithjason.com/rspec-mocks-stubs-plain-english/ If you’re confused about mocks and stubs, you’re not alone. In my experience very few people understand them. In this post I’ll attempt to help clarify the matter, particularly in the context of Rails/RSpec. [more inside]
Hanami v2.0.0.alpha1
First preview of the 2.0 series. App simplification, new router, rewritten actions, fresh code reloading strategy.
validates number of attached files (for active storage)
new version of gem now supports min/max number of uploaded files. thanks to @ivanelrey
“!” and “?”: Understanding One of Ruby’s Coolest Naming Conventions
“Guys, are the ! and ? that we find at the end of method names a convention of Ruby, RoR, or whom else?” [more inside]
Hosting microservice SPAs on Azure Storage Account blobs proxied by Nginx [prototype]
As you may know simmilar to AWS S3, with Azure Storage Account blobs you can host static website on these service. (so you pay few cent per month hosting) [more inside]
ValueSemantics—A Gem for Making Value Classes
ValueSemantics is a gem for making value classes, with attribute defaults, validation, and coercion. This article also covers some of its design considerations, such as using exceptions to catch developer mistakes, extensibility, being unobtrusive, integration continuity, stability, thin DSLs, and “no setters” immutability.
Rails Routes, HTTP Methods and SQL Queries
One of the most important things to learn when trying to understand Rails is how HTTP Methods work with Rails Routes and SQL Queries. In this post we go in-depth to explain how they all work to gather
Maily v0.9.0 - external mailers support
A new version of Maily (https://github.com/markets/maily) v0.9.0 has been published 🚀. Mainly, includes a new feature to simplify integration with emails from other gems. Example, with Devise:
Requiring a file or library in Ruby
In this article we’re going to explore the following topics:
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.
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.
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:
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:
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
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: