ActiveStorage does not provide any built-in way of implementing authentication for the available DirectUpload endpoint in Rails. When using...
...are three dimensions you can control when scoping routes: path helpers, URL segments, and controller/view module. scope module: 'module', path: 'url_prefix', as: 'path_helper_name' do resources :examples, only...
...and expose data over events used below. const controller = new CustomDirectUploadController(input, input.files[0]) controller.start(storedInput) } const hasFile = function() { return (storedInput?.value !== undefined && storedInput?.value !== '') || input.value !== '' } const updateClearButton = function() { clearButton.classList.toggle...
Every Rails response has a default ETag header. In theory this would enable caching for multiple requests to the same...
To attach files to your records, you will need a new database column representing the filename of the file...
Rails is our web framework. Goals Be able to write a simple Rails application. Understand how Rails talks to the...
When you allow file uploads in your app, a user might upload content that hurts other users. Our primary concern...
...abort it manually by using an AbortController: let controller = new AbortController() countDown(10, { signal: controller.signal }).then( () => console.log("10 seconds have passed"), (reason) => console.log("Countdown failed:", reason) ) controller.abort() /* prints "Coundown failed...
If you run a Rails app that is using Turbo, you might observe that your integration tests are unstable depending...
When Paperclip attachments should only be downloadable for selected users, there are three ways to go. The same applies to...
...expected_resource = expected_resource @expected_options = expected_options end def matches?(controller) @controller_class = controller.class @actual_resource = @controller_class.instance_variable_get('@aegis_permissions_resource') @actual_options = @controller_class.instance_variable_get('@aegis_permissions...
Here are some popular mistakes when using nested forms: You are using fields_for instead of form.fields_for.
Rails offers several methods to manage three types of different cookies along with a session storage for cookies. These...
Web security basics Einführung in die Web Security 🇩🇪 provides essentials for the topic of this card. Read following chapters:
In development, we store files using ActiveStorage's disk service. This means that stored files are served by your Rails...
...specs will mock a lot of rails behavior and render the view independent from the controller-logic. Therefore it will be more applicable to test views within request specs. But...
Rails partials have a lot of "hidden" features and this card describes some non-obvious usages of Rails Partials.
...link[rel*=icon]')?.href || '/favicon.ico' timeout ||= 6000 const controller = new AbortController() const timeoutTimer = setTimeout(() => controller.abort(), timeout); try { await fetch(path, { cache: 'no-store', signal: controller.signal }) return true } catch(error) {
ActiveRecord gives you the :include option to load records and their associations in a fixed number of queries. This is...
All direct child directories of app are automatically added to the eager- and autoload paths. They do NOT create a...
When your Rails application offers downloading a bunch of files as ZIP archive, you basically have two options:
The git doc states on the difference of these two commands: git-restore[1] is about restoring files in the...
Built-in matchers Get an overview of all the matchers that are built into RSpec. Play with some of...
Understand why we test: Low defect rate without a QA department. Customer acceptance testing can concentrate on new features...