...to give an element a glossy or three-dimensional feel, box shadows work much better for this. This is because linear gradients always stretch to the full size of the...
When you have a program running in a hidden X screen (like with Xvfb for Selenium tests) you may want...
When loading a database dump created with pg_dump into your database, you might run into an error like
...only a millisecond or two: class FatModelMaterializedJson < ApplicationRecord def self.refresh ActiveRecord::Base.connection.execute(<<~SQL) DO $$ BEGIN IF ( (SELECT last_refreshed_at FROM aggregated_names LIMIT 1) < (SELECT MAX(updated_at) FROM...
You can download .gem files using gem fetch: gem fetch activesupport consul This will produce files like active-support-5.0.0.gem and consul-0.12.1.gem...
...a publicly available service) Understand that Safari and mobile Safari (for iOS) usually lag behind other browsers when it comes to feature support. "Transpilation" and "polyfills" are both techniques to...
...ES versions at the top. English MDN Web API Reference MDN is maybe the best reference for JavaScript, HTML and CSS features. Google my-feature mdn is a quick way...
The recommended additional setup of the spreewald gem, a useful set of cucumber steps, includes adding a file for defining...
...default when assigning attributes. It works good for a small number of attributes, but becomes more difficult to read when using multiple attributes. Example: class User def initialize(salutation, first...
@newsletter = newsletter end end User.new( 'Mr.', 'John', 'Doe', 'Potsdamer Platz 1', '10117', 'Berlin', '+49 0151 1122334455', 'john.doe@example.com', true ) Using keyword arguments Using keyword arguments is easier for others...
...whole test suite's settings because of a pending test, you can disable this behavior for pending features only. To make any pending call reconfigure the current cassette, you can...
I recommend install Node.js using nvm. This way you can have multiple Node versions in your ~/.nvm. You also won...
...Tue, 09 Oct 2018 In most of the cases it would be better to use Date.strptime as you can provide a date or time pattern to match against. Date.strptime('Foobar...
...blocks or confusingly sometimes also procs Those with "method semantics", called lambdas lambdas They behave like Ruby method definitions: They are strict about their arguments. return means "exit the lambda...
...the lambda literal -> (since Ruby 1.9.1) test = ->(arg) do puts arg end blocks They behave like do-blocks or simply "segments of code": They try to be smart about their...
When you created a project on the Google API Console which is not being used, you may receive an e...
Occasionally you need to do something directly on the server -- like having all records recalculate something that cannot be done...
CSS transitions are a simple animation framework that is built right into browsers. No need for Javascript here. They're...
fake_stripe spins up a local server that acts like Stripe’s and also serves a fake version of Stripe.js...
GRASP (object-oriented design) Single Responsibility Principle Tell, Don't Ask Best practices for writing code comments Read the following chapters from our book Growing Rails Application...
...has_many :items validates_presence_of :recipient_address, :number end class Invoice::Item < ApplicationRecord belongs_to :invoice belongs_to :product validates_numericality_of :units end class Product < ApplicationRecord validates_presence...
...helper in many views, but in the index view I hide the label to better fit the layout. Here is the helper: module IconHelper def icon(*args, &block) options = args.extract...
It is possible to access Rails config (for example secrets) from within your webpack bundles, thanks to rails-erb-loader...
It's not a good idea to leave data objects mutable. They should behave like integers. Ruby's Data would have already enforced that. Because I used a regular...
...attr}=" do |value| if @readonly raise 'Readonly' else super(value) end end end Weird behavior changes from composed_of The method composed_of accepts the option :mapping, which is required...
...globstar shell option, it is probably disabled: $ shopt globstar globstar off In that case, ** behaves just like * and will match exactly 1 directory level. $ ls spec/**/*_spec.rb spec/models/user_spec.rb
...clarify: This not only disables the memoization, but will also return wrong results! The best solution is to use the Memoizer gem instead...
While it might be tempting to set it per project (other devs might benefit from it), you need to do it each time for every project "pollute" a project...
...very nasty fails. Below are the basic changes you need to perform and some behavior you may eventually run into when upgrading your application. This aims to save you some...
...in your uploaders... def extension_white_list %w[jpg jpeg gif png] end must become def extension_allowlist %w[ jpg jpeg png gif ] end Also, every uploader must define allowlists...