So you downloaded inaction_mailer, and you had a folder full of e-mails generated while writing your app?
Easily show multiple, overlapping events across calendar days and rows.
A simple implementation of an Identity Mapper for Active Record.
Unfortunately vanilla Ruby modules lack support for many idioms popular in modern Ruby. Most importantly, we have become accustomed to...
Steak is like Cucumber but in plain Ruby.
Rack middleware for rate-limiting incoming HTTP requests.
File upload solution that supports form roundtrips when a validation fails.
Here is a set of additive color model conversion algorithms that I found published on Wikipedia and have implemented in...
We recently decided our CI server needed an overhaul. I really enjoyed Integrity as a build server, but after trying...
What do we expect from the custom finder? We expect that it should find assets A, B, C and should...
All ActiveRecord associations except for has_many :through support callbacks for pre- and post-insertion/deletion via the following, self...
Pour color on your Rails console with awesome_print. Turn confusing long strings into formatted output. Have objects and classes laid out clearly whenever you need it. Put gem 'awesome...
...print', :group => :development into your Gemfile. Now on the Rails console you have the command ap that will give you a colored, formatted output of whatever you pass it. See...
Webpacker can automatically create an icon font from SVG files, which is really handy. When you're using the asset...
The Rails secret_token must be unique for each application and any instance of it. If not, someone could exploit this by creating a user with ID = 1 (e.g. on...
...current production users, leaving the production token unchanged: prefix the existing secret_token with #{Rails.env unless Rails.env.production?}. Note: There may be tokens in single quotes that include backslashes, double quotes...
...reason), you can open doc/dependency_decisions.yml and edit the last entry. A word on bower-rails Bower-rails is a Bower wrapper that simplifies Rails integration. Unfortunately, it makes it harder...
...to integrate Bower with LicenseFinder. To get things running, follow these steps: Symlink bower-rails's bower.json to the project root: ln -s vendor/assets/bower.json Create a .bowerrc file at the...
By default, Rails views escape HTML in any strings you insert. If you want to insert HTML verbatim, you need to call #html_safe. However, #html_safe does not "unescape...
...is return a SafeBuffer which will handle future concatenations differently than a String. How Rails auto-escapes in views Rails renders your views into a SafeBuffer. It starts with an...
...provide any built-in way of implementing authentication for the available DirectUpload endpoint in Rails. When using DirectUpload as JS wrapper in the frontend, be aware that its Rails endpoint...
...anyone to upload an unlimited amount of files to your storage. The DirectUploadController from @rails/activestorage bypasses your form controller because it uploads the file using an AJAX request that runs...
...Post < ApplicationRecord belongs_to :user validates :user, presence: true # Default for belongs_to on Rails 5+ end I18n has the feature of falling back one level to look up translations...
...at: Last change user: name: Name role: Access level # updated_at not needed here, Rails will use the definition from above Another feature of I18n is optional pluralization. When calling...
Rails' url_for is useful for generating routes from a Hash, but can lead to an open redirect vulnerability. Your application's generated route methods with a _url suffix are...
...Open Redirect vulnerability. It's as simple as passing a host=evil.tld URL parameter. Rails would see url_for(..., host: "evil.tld") and happily generate a URL to that foreign host...
...ActiveRecord::Rollback, read on. The basic problem Not all databases support nested transactions. Therefore, Rails will sometimes silently ignore a nested transaction and simply reuse the other transaction. However, a...
...cause a roll back! To avoid this unexpected behaviour, you have to explicitly tell rails for each transaction to indeed use proper nesting: ActiveRecord::Base.transaction(joinable: false, requires_new: true...
In medium-sized to large Rails applications, asset compilation can take several minutes. In order to speed up deployment, asset precompilation can be skipped. This card automates the process.
...to set the default_url_options of ActionMailer: Hardcoded solution (preferred solution when using Rails with ActiveJob/Sidekiq or Cronjobs) Dynamic solution 1. Hardcoded solution When you are sending mails from...
...e.g. ActiveJob/Sidekiq or Cronjobs, you need to configure the default_url_options in your Rails configuration. # config/application.rb as fallback/default Rails.application.default_url_options = { host: 'localhost', port: 3000, protocol: 'http://' } Rails.application.configure do...
...column representing the filename of the file. To do this, add a new migration (rails g migration ) with the following content: class AddAttachmentToNotes < ActiveRecord::Migration[6.0] def change add_column...
...change the column details to fit your purpose. Run it. 1) Deliver attachments through Rails The first way is to store your Carrierwave attachments not in the default public/system, but...
...echo the environment setting in our application layout: <%= tag :meta, name: 'feature:polling', content: Rails.configuration.feature_polling %> Now polling is disabled by default for all tests. Our test suite has immediately...
...scenario 'The project list is updated periodically' do # Enable polling for this test allow(Rails.configuration).to receive(:feature_polling).and_return(true) # Go to the projects index and see an...