Using Capistrano, we usually have some array configurations in the config/deploy.rb file, like set :linked_files, %w[config/database.yml], so in...
Website that offers lots of different kinds of HTTPS configurations, bad or good or complicated. They also offer a dashboard...
Element finding is a central feature of Capybara. Since #find is normally used to get elements from the current page...
Webpack is the future. We're using it in our latest Rails applications. For tests, we want to compile assets...
If you try to listen to events on elements that are nested inside a , Firefox will stop event propagation once...
...fills in the query "foo" Also see An auto-mapper for ARIA labels and BEM classes in Cucumber selectors
In modern default RSpec configurations, your tests are usually run in random order. This helps to detect "flickering" tests that...
When you need to find out in which kind of spec you are during run-time, it's definitely possible...
Note Using rem only ever makes sense when the root font size is dynamic, i.e. you leave control to the...
For performance improvements (and to remove the need for eager loading), the ActsAsTaggableOn gem supports caching your tag lists directly...
So you added a new callback to your model that (e.g.) caches some data when it is saved. Now you...
Regular expressions in Javascript are represented by a RegExp object. There also is a regex literal as in many other...
...other methods within the Method class are useful for advanced metaprogramming, though this is beyond the scope of this card. Also see Ruby: Finding where a method is defined
...many :taggings, dependent: :destroy + has_many :posts, through: :taggings +end app/models/tagging.rb +class Tagging < ApplicationRecord + belongs_to :post + belongs_to :tag + + validates :post, uniqueness: { scope: :tag } +end app/controllers/posts_controller.rb def post_params...
...many :taggings, dependent: :destroy + has_many :posts, through: :taggings +end app/models/tagging.rb +class Tagging < ApplicationRecord + belongs_to :post + belongs_to :tag + + validates :post, uniqueness: { scope: :tag } +end app/controllers/posts_controller.rb def new
...optional on association declarations with a symbol, lambda or proc. Explanation Association declarations like belongs_to support the option optional. This option does not support symbols, lambdas or procs. If...
...the presence of the associated object won't be validated. Example Bad class Note belongs_to :owner, optional: :draft? end note = Note.new(state: 'created', owner: nil) note.valid? # => true Good
RSpec lets you define the arguments with which you expect a method to be invoked: subject.should_receive(:say).with('hello...
When accepting GIF images, you will also accept animated GIFs. Resizing them can be a time-consuming task and will...
...by doing date on the shell. E.g. our main application servers are running on Berlin (CEST) time, but this will differ on other machines. Rails also assumes that datetime fields...
...Rails 2, open config/environment.rb and comment or remove the config.time_zone line: # config.time_zone = 'Berlin' In order to disable time zone conversion in Rails 3 or newer, open config/application.rb and...
track down warnings and to see failing specs immediately or to get an overview of the core...
When you use a belongs_to or has_many macro you might be surprised that the methods that it generates does not override a method with the same name. Take...
class Project < ActiveRecord::Base def user "foo" end belongs_to :user end Project.new.user still returns "foo". The reason for this is that what belongs_to does is actually...
...applications is to make the observe frequency low enough that out-of-order responses become unlikely enough. Try to poll the query field for changes every 0.75 seconds or longer...
When testing your command line application with Aruba, you might need to stub out other binaries you don't want...
When you do a bitwise copy using the dd tool you will not see any output until it completes or...
When deploying a Rails application that is using Webpacker and Capistrano, there are a few configuration tweaks that optimize the...