Say you have a User with a Carrierwave attribute #avatar: class User < ActiveRecord::Base mount_uploader :avatar, AvatarUploader end
Greg Molnar has written a neat article about creating a single-file Rails app. This is not meant for production...
In order to have monitoring for Sidekiq (like queue sizes, last run of Sidekiq) your application should have a monitoring...
You can use constraints in your routes.rb to avoid getting ActionView::MissingTemplate errors when wrong routes are called. Instead, the...
If an view spec crashes due to undefined helper methods, you can enable this option: # config/application.rb config.action_controller.include_all_helpers = true...
Rails has the handy controller method send_file which lets us download files easily. We can decide whether the file...
Find conditions for scopes can be given either as an array (:conditions => ['state = ?', 'draft']) or a hash (:conditions => { 'state' => 'draft...
Building application assets with esbuild is the new way to do it, and it's great, especially in combination with...
We have often felt the pain where our models need to serve too many masters. E.g. we are adding a...
The information in this card is only relevant for Rails 2.3-era apps. This note gives a quick introduction into...
You are not using javascript tests The file is served from a public folder (not via controller) Problem description...
:plain window.addEventListener('load', () => { ... }); CSP mit Rails Demo Konfiguration via config/initializer/content_security_policy.rb Überschreiben in einzelnen Controllern Nonce-Support für javascript_tag Probleme mit CSP Fehlkonfiguration Quiz: Wo ist das Problem?
When a controller action redirects to an external URL (like http://somehost.com/some/path) you will find that this is hard...
This will show you how to create a RSS feed that the Feed Validator considers valid. Note that RSS is...
Rails 5 (don't know about the others) comes with an initializer wrap_parameters.rb. Here you can tell rails to wrap...
When you create a temporary file (e.g. to store a generated Excel sheet) and try to send it to the...
If in your application your users pass along params that result in filenames, like invoices/generated?number=123. This could be...
...it does itself. Like that: describe 'before update' do it 'should do something' do controller.should_receive :do_something controller.send :before, :update end
Rails' params hash contains any request parameters (URL parameters or request payload) as well as routing parameters like :controller, :action...
You won't usually have to do this. It's OK to route all formats to a controller, and let...
Don't write resources :people, :concerns => :trashable Write resources :people do concerns :trashable end Why Writing a controller...
You know that Devise offers RSpec test helpers for controller specs. However, in request specs, they will not work.
This is a visualization of the files that will be generated by some useful rails generators. Invoke a generator from...
Even when you're using bundler, it might be significant in which order your gems are listed in your Gemfile...