Deep dive Okay, so the example above has at least one obvious benefit: You do not have to put self.table_name_prefix = "universe_" into each of your classes...
...it. It's not read at all. Here is why (follow links for a better understanding): An ActiveRecord class will pick the table_name_prefix of any of its module...
CarrierWave comes with a set of default configuration options which make sense in most cases. However, you should review these...
ActiveSupport (since 4.1) includes test helpers to manipulate time, just like the Timecop gem: To freeze the current time, use...
If you're responsible for gatekeeping in a projects, here is a guide, what to do. In order to reduce...
When selecting records in a date range, take care not to do it like this: start_date = Date.parse('2007-05...
It might sometimes be useful to check whether your Rails application accesses the file system unnecessarily, for example if your...
Below is a strict, but still workable Content Security Policy for your Ruby on Rails project. Use this CSP if...
You can convert git commits into patch files. Those can be used to apply to a different repository [1] or...
Download buttons can be difficult to test, especially with Selenium. Depending on browser, user settings and response headers, one of...
To retrieve only unique combinations of the selected attributes: You can omit rows, where all selected columns are equal with...
...rendering quality is now fine in recent versions of wkhtmltopdf (0.12+). You will never beat LaTeX if you need perfect font rendering. If you are observing strange behavior when including...
...might experience that your application "locks up" whenever you request a .pdf route. This behavior is caused by a deadlock: The Rails process is trying to render the page to...
For webpages to load fast it's recommended to optimize images. Ideally an image's file size should be as...
Developing or debugging SAML functionality can be a hassle, especially when you need to go back and forth with someone...
...won't need this for single lines of text. In this case it is better to just use the text-overflow property: Use CSS "text-overflow" to truncate long texts...
...starts wrapping within its container. This is most probably because there is no defined behavior in case multiple text contents are rendered next to each other (horizontally) and the clamping...
You cannot use Array#join on an array of strings where some strings are html_safe and others are not...
def self.acquire(name) already_acquired = definitely_acquired?(name) if already_acquired yield else begin create(:name => name) unless find_by_name(name) rescue ActiveRecord::StatementInvalid # concurrent create is okay...
begin result = nil transaction do find_by_name(name, :lock => true) # this is the call that will block acquired_lock(name) result = yield end result ensure maybe_released_lock...
Due to the way we setup Jasmine tests in our projects, you may run into various errors when Jasmine boots...
Rails default config uses the ActiveSupport::Cache::NullStore and disables controller caching for all environments except production: config.action_controller.perform_caching = false...
Why secure-only cookies used to be necessary Cookies have an optional secure flag. It tells the browser to not...
Full-text search can reach its limits in terms of flexibility and performance. In such cases, trigram indexes (pg_trgm...
...used when you are working on a branch and make a new commits which belongs to a previous commit. If the previous commit is the last commit, you can also...
Even though the process in #1 could be used for this it can become quite tedious if you have a large commit and might have already done this and...
In Rails 8 the behavior of the rails db:migrate command has changed for fresh databases (see PR #52830). Before Rails 8: The command runs all migrations in the folder...
When deleting a record in your Rails app, Carrierwave automatically takes care of removing all associated files. However, the file...
Starting with ChromeDriver 127, if your application displays a beforeunload confirmation dialog, ChromeDriver will immediately close it. In consequence, any automated tests which try to interact with unload prompts will...
...such dialogs. This means that we want to use the BiDi driver when testing beforeunload prompts. Enabling the BiDi WebDriver Using Capybara, simply set the :web_socket_url option to...