...routes, so we can write it as follows. class RackLoggerWithSilencedActiveStorageRoutes < Rails::Rack::Logger def call(env) if env['PATH_INFO']&.start_with?("#{Rails.configuration.active_storage.routes_prefix}/") Rails.logger.silence do super end else

...painfully slow RegExp text matching or add the normalize_ws: true option to every call of a Capybara finder. I suggest that you rather configure it globally, which also affects...

...virtual environment. (They are located in ~/.venv/your-environment-name/bin/). To leave your virtual environment, you may call deactivate. To enter your venv again later, you must source it again, as described above...

If you expect method calls in RSpec 3, be aware that the argument matchers use very liberal equality rules (more like === instead of ==). For example: expect(subject).to receive(:foo...

...span&t;bar&lt;/span&gt;' Bad The solution is not to call html_safe on the joined array and if you thought it would be, you don't understand...

...how XSS protection works in Rails. Calling html_safe on the joined array will incorrectly bless the complete string as safe: [safe_string, unsafe_string].join(' ').html_safe # will incorrectly...

...additional scripting. While you may bind to the window's resize event, that might call your event listener many times. A better way is to subscribe to changes of the...

...code base. It should be encapsulated in single files or folders. Be easy to call: A service should always try to have a simple public interface, even if that causes...

...pages, you should use tel: links so smartphone users can click those numbers to call someone. Here is a small helper method that you can use to simplify this:

...code (sometimes used when combining international and local numbers, see example below) as the called number should not include that zero. def tel_to(text) groups = text.to_s.scan(/(?:^\+)?\d+/) if groups.size...

module WebpackerCompileOnce COMPILE_WAIT_TIMEOUT = 180 COMPILE_WAIT_POLL_INTERVAL = 0.3 def compile # Calling #compile will at least once compute SHAs over the content # of all files in app...

...parallel_tests process has finished compiling. def wait_until_fresh # We're going to call #fresh? a lot. This will call #watched_files_digest, which # computes SHAs over the contents...

thegnar.com

...you to use Capybara Finders methods (e.g. #find) on the doc element and then call matchers on that element: link_element = doc.find('a') expect(link_element).to have_selector('.nav...

...by default, such that rendered is converted once one of Capybara's matchers is called on it, it's default type is still a String. (As noted in the Capybara...

makandra Curriculum

...street # => "Foo Avenue 77" Hint You can convert any object to a string by calling #to_s on it. The matching should be case-insensitive. Also when the query string...

...random_each. The method should iterate through the array elements in random order and call the given block for each iteration. For example, the following should work...

evilmartians.com

...even displays helpful flamegraphs for better visualization. Provides actionable insights like: Number of factory calls in each test and the time spent on each. Breakdown of associated records created unintentionally...

Dir[Rails.root.join("spec/controllers/shared_examples/**/*.rb")].each {|f| require f} Make sure you don't call your examples files like ..._spec.rb, else RSpec will believe they're actual spec files and...

...def helper_method 42 end end World(Helpers) features/step_definitions/step.rb Then /^the helper method is called$/ do expect(helper_method).to eql(42)

...das SNS Topic Benachrichtigungen von AWS Config entgegen nehmen. Anschließend soll diese per API-Call ein Issue in deinem Gitlab Projekt erstellen. Versuche so früh wie möglich deine Lambda via...

...to load records and their associations in a fixed number of queries. This is called preloading or eager loading associations. By preloading associations you can prevent the n+1 query...

...order => 'created_at DESC', :include => :author) end end This controller action works until someone calls the action with a category containing a dot character. This will make ActiveRecord join the...

...know anything about the API internals. It feels more natural, that you don't call client internals from your models. Only the public methods like GithubClient::Client.new.users('makandra GmbH') or...

...def log(message) message.each_line do |line| Rails.logger.info(line.rstrip) end end You can then call log with your multi-line string and each line will be tagged. To improve even...

makandra dev

Check if ~/.cache/selenium/se-metadata.json exists. (It contains a "ttl" timestamp of its last/next anaytics call. You can parse it with Ruby's Time.at.) Opt out You can opt out either...

kernel.org

Now, another commit will be checked out. See if the issue persists and call git bisect good or git bisect bad, resulting in another commit being fetched and so...

...window rendering effects added by a window manager, and browsers don't provide a callback that would allow to detect the end of windows size changing process. Capybara provides a...

...WebDriverError, 'Switch to desired window before changing its size' unless handle == :current # Chromedriver API call named "set_window_rect" set_window_rect(width: width, height: height) end end

...inlined, because it is only used once. Let's use a similiar input, but call fn() twice: function fn() { if (a) { return 'foo' } else if (b) { return 'foo' } else {

...console.log(o()) Note how: The function remains in the compressed output, as it is called more than once. The function name has been shortened to o, as it is not...

stackoverflow.com

To reload a single-item association in Rails 5+, call #reload_ : post.reload_author In older Railses you can say post.author(true...

makandra Curriculum

...Write the same script in Ruby. What do you have to do to just call it from the command line without using the ruby command directly? Learn about the "shebang...