...its generators with Rails::Generators.invoke ARGV.shift, ARGV. From inside a Rails generator, you may call the inherited Thor method invoke(args=[], options={}, config={}). There also is a generate method which...
...will run the generator in a subprocess. Call it with generate 'generator_name', 'command line args'. Expected (hard-coded) directory structure of a generator #{generator namespace, e.g. rails}/ #{generator name...
...to add expectations on objects that will only be created when your code is called. If you have older rspec, you could use expect_any_instance_of, but with the...
...here is `and_wrap_original` validator = method.call(*arguments) # <- the original method (`cast`) is explicitly called expect(validator).to receive(:valid?) # <- a expectation on the then newly created object is added...
...When a domain name is given, the non-interactive mode is used. Call nslookup without a url to start interactive mode. With interactive mode you just have to type in...
...the first line is your DNS resolver. To use a specific one, you can call nslookup like this: >nslookup heise.de 8.8.8.8 Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer:
cache_id && @revalidated_cache_id != cache_id end end end end If you called check_blacklist!(file) and check_content_type_blacklist!(file) in this trait, these lines should...
...active or not. This is done by settings the if:...
...kwarg within the version call. For example, if you migrated legacy videos from the old server, you still want to...
...time, use travel: travel 1.day All those methods may also receive a block to call and restore time afterwards. If you don't provide a block, you must call travel...
When you are using lambdas in RSpec to assert certain changes of a call, you know this syntax: expect { playlist.destroy }.to change { Playlist.count }.by(-1) While you can define multiple...
...playlist.destroy } .to change { Playlist.count }.by(-1) .and not_change { Video.count } The above example will call playlist.destroy only once, but test both assertions. Note When you chain multiple Capybara matchers using...
If you already selected an element and want to get its parent, you can call find(:xpath, '..') on it. To get the grand-parent element, call find(:xpath, '../..'). Example
...to abort async code is that your function takes a AbortSignal { signal } property. The caller can use this signal to send an abort request to your function. Upon receiving the...
...countDown() abortable Here is a variant of countDown() that may be canceled by the caller before the time has elapsed: function countDown(seconds, options = {}) { return new Promise((resolve, reject) => {
...is a slightly abbreviated version: What changed When the last argument of a method call is a Hash, Ruby < 3 automatically converted it to to Keyword Arguments. If you call...
...in Ruby >= 3 that accepts keyword arguments, either explicitly or via **kwargs, you cannot call it with a hash. I.e. def explicit_kwargs(x:, y:) # ... end def splat_kwargs(**kwargs...
...nested_form.object will be nil. The :reject_if option lambda in your accepts_nested_attributes call is defined incorrectly. Raise the attributes hash given to your :reject_if lambda to see...
...for already iterates for you. You used form.fields_for |nested_form|, but continue to call form helpers (like text_field) on the containing form instead of nested_form.
Rails 3, 4, 5, 6 config/application.rb config/environment.rb before the initialize! call (we don't usually edit this file) The current environment, e.g. environments/production.rb Gems Vendored plugins All initializers in config/initializers...
config/environment.rb after the initialize! call (we don't usually edit this file) Your own code from app Rails 2 Code in config/preinitializer.rb (if it exists) environment.rb, code above the...
...studies. It is based on an article written by Stephen Curtis. Table of Contents Call Stack Primitive Types Value Types and Reference Types Implicit, Explicit, Nominal, Structuring and Duck Typing...
...Operators, Type Arrays and Array Buffers DOM and Layout Trees Factories and Classes this, call, apply and bind new, Constructor, instanceof and Instances Prototype Inheritance and Prototype Chain Object.create and...
class Movie < ApplicationRecord normalizes :title, with: -> { _1.strip } end Tip Normalization lambdas are not called for nil values by default. To normalize nil values, pass an apply_to_nil: true...
...class Movie < ApplicationRecord normalizes :title, with: Normalizers::StripNormalizer end The with keyword accepts any callable object that takes the attribute’s value as its only argument. To comply with this...
...name_prefix is used. (see full_table_name_prefix in ActiveRecord::ModelSchema). The relevant call to full_table_name_prefix happens in compute_table_name. And compute_table_name is...
...called only if no table_name has been defined for a class (see reset_table_name and table_name). This is why you might be tempted to fix the odd...
...is about valid files, e.g. matching extension white- or blacklists. "Processing" is about process calls, e.g. for changing image resolution. "Download" is when CarrierWave loads a file from a remote...
CarrierWave provides CarrierWave::Uploader::Base.clean_cached_files! for that already, but you need to call regularly from your preferred scheduler. For example, when using whenever, you should have something like...
...files for images, fonts etc. Most applications will use a single pack (we often call it main), some applications might for example use separate frontend and backend packs.
...yarn upgrade [package] yarn upgrade [package]@[version] yarn remove [package] Under the hood, Yarn calls npm for you. Do not use the npm command yourself. Do not manipulate package.json yourself...
...patch in routing-filter as it still expects an array of route data when calling super, but never actually calls the block that now needs to be called. Due to...
...this monkey patch.' end # We cannot prepend a custom extension module here because we call `super` in this method which should call the Rails # #find_routes-method and not the...
When you're nesting setTimeout(f, 0) calls, your browser will silently increase the delay to 5 milliseconds after the fourth level of nesting. This is called "timeout clamping" and...
...a similar note, all major browsers have implemented throttling rules for setInterval and setTimeout calls from tabs that are currently in the background. You can test it yourself by running...
...Support for combining structurally incompatible relations with and Pull request: Ignore joins on #and calls Alternative: Use SQL snippets When you call #where() with an SQL snippet string instead of...
...JavaScript via Unpoly compilers. Haml Attribute Syntax # Ising hash rockets and string symbols (method calls) = form.text_field :name, 'date-picker': true # Curly braces or brackets (elements) %div.container{ id: 'main', 'data...
...for simple scalar values Use up-data for objects, arrays, and nested data Always call .to_json on Ruby objects for up-data Use ES6 destructuring: (el, { prop1, prop2 })
RubyMine has a collaboration feature called "Code With Me". Using it, you can invite someone into your local editor to work together. This is nicer to the eyes and much...
...icon once a session is running. Features See other people's cursor Follow others Call others to follow you Work in full sync Work independently, but still in the same...
...provides a database-based model level mutex for MySQL. You use it by simply calling Lock.acquire('string to synchronize on') do # non-threadsafe code end You must make sure the...
...Only one process can enter the block using the same string, so a concurrent call to another Lock.acquire('string to synchronize on') will block, whereas Lock.acquire('some other string') will...
...before continuing - the event could prevent the default behavior. Luckily there is a concept called passive event listeners which is supported by all modern browsers. Below are the key parts...
...analysis indicates that the majority of touch event handlers on the web never actually call preventDefault(), so browsers often block scrolling unnecessarily. By marking a touch or wheel listener as...
...it_should_act_like from our spec_candy.rb (note the /behave/act/). It allows you to call a standard shared example group with parameters. Some stupid examples follow to show how it...
it_should_act_like 'string equaling another string', :string => 'foo' end If you call it_should_act_like with a block, it will be made available as block: