...purpose of this card. Update it once a day (using whenever) Tip Consider the best place to put the new logic. Should it be an existing class or new classes...

...plain RSpec mocks ("stubs") to replace the HTTP request to the API with scripted behavior. Can you minimize the number of lines of code that now no longer run during...

Spammers have started abusing other application to send their spam. This works like this: The application has some form that...

makandra dev

Knowing when to refactor Just feeling like refactoring is not a good reason to do it. Make an educated decision...

Resources RubyGuides: Mastering Ruby Regular Expressions Using regular expressions in JavaScript Testing regular expressions visually Regular Expressions: Quantifier modes...

makandra dev

...t raise an error. Instead, rescue the exception type that you are expecting: @user = begin User.power_find(something) rescue ActiveRecord::RecordNotFound User.new end This also applies to the quite popular...

...nil" and "full" rescue blocks that don't explicitly rescue away an error class: begin # do stuff rescue # rescues any StandardError end Note that there may be cases where you...

ruby-lang.org

Ruby 3.0 introduced a breaking change in how it treats keyword arguments. There is an excellent blog post on the...

kernel.org

...John Doe <user@example.com> Date: Thu Dec 23 13:37:00 2010 +0100 make everything better Once you are done bisecting you can go back with git bisect reset

github.com

When handling nested hashes the RSpec output is often hard to read. Here the gem super_diff could help.

makandra dev

...change the rendered html, some variation of @message.content.body.to_rendered_html_with_layout Changing the behavior of the editor You may want to add some functionality to the editor or remove...

...addEventListener("trix-action-invoke", event => { const { editor } = event.target if (event.actionName === "x-horizontal-rule") { // ... } // Add behavior for the other buttons // ... }) Check the Trix README to check what you can do.

This cards describes an example with a Github Client on how to keep your Rails application more maintainable by extracting...

...t have control of. Solutions Don't log SQL queries. This is the default behavior of rails but can be changed in the config/environment/production.rb file: config.log_level should not be...

DirectUpload allows you to upload files to your file storage without having to wait for the form to submit. It...

...would allow to detect the end of windows size changing process. Capybara provides a better way to manipulate the browser window which you should use instead: page.current_window.resize_to. Good: Capybara...

...as isolated (more unit like) tests, one might want to test some cookie dependent behavior as a request, helper or model spec too. Since the rspec documentation on testing cookies...

...that into a class to DRY up your code and write solid unit tests. Beware that your class will not be able to read the cookies, since they are only...

makandra dev

...installation supports YJIT, by running: $ ruby --yjit -v ruby 3.3.4 (2024-07-09 revision be1089c8ec) +YJIT [x86_64-linux] If YJIT is not available, the output of this command will...

...time of queries. While they serve similar purposes they do have some differences in behavior and implementation. PostgreSQL Timeout Type: statement_timeout Scope: Applies to all types of SQL statements...

...INSERT, UPDATE, DELETE). Units: Can be specified in various time units (milliseconds, seconds, minutes). Behavior: If any statement exceeds the specified timeout, PostgreSQL raises an error indicating the statement was...

If you use third party APT sources you might end up with unmaintained packages after removing the external source or...

...Rails docs, e.g. Array#to_sentence String#dasherize Hash#slice Object#presence Libraries The best way to learn about a Ruby gem, Javascript libary, etc. is often to find the...

http://unpoly.com https://lodash.com/ https://fontawesome.com/icons Web Platform (HTML, JavaScript, CSS) The best reference to look up information on HTML tags, JavaScript features or CSS properties is the...

blog.saeloun.com

Rails' fragment caching caches subtrees of an HTML document tree. While constructing that tree though, it can be really hard...

If your app does not need to support IE11, you can use most ES6 features without a build step. Just...

...use version 5.2.0 or newer to ensure you can deploy via Capistrano. It's best to use the latest version, as there were multiple issues between 5.2.0 and 7.3.0.

Some tasks in a web application are better not done live when a user request a page, but in the background. Examples are longer running tasks tasks that are not...

...been accepted for 7 days. Learn about Sidekiq Read Sidekiq's Readme Read Sidekiq best practices Read Sidekiq Error Handling Understand how to schedule jobs, and work them off

When you find similar groups of expect calls in your tests, you can improve readability by extracting the group into...

I encountered a unlucky behavior of byebug 11.1.3 (the most recent version at time of writing) when using it with Rails 6 and it's new autoloading component, zeitwerk. There...