apidock.com

...may override the default accessors (using the same name as the attribute) and simply call the original implementation with a modified value. Example: class Poet < ApplicationRecord def name=(value)

...behaviors to your tests based on their type tag, for example enabling you to call get and post in specs with the tag type: :request. Alternatively you can skip these...

...How to get the path to ../CHANGELOG.md independent of the working dir of the caller changelog = File.read(changelog_path)

...further actions here Ruby >= 2.0 changelog_path = File.expand_path('../CHANGELOG.md', __dir...

simple_format ignores Rails' XSS protection. Even when called with an unsafe string, HTML characters will not be escaped or stripped! Instead simple_format calls sanitize on each of the...

makandra dev

...query param than foo, e.g. https://www.example.com/old_location?another_param=1. This is because url_for will call to_h on ActionController::Parameters, which will raise if there are unpermitted parameters.

When you mocked method calls in RSpec, they are mocked until the end of a spec, or until you explicitly release them. You can use RSpec::Mocks.with_temporary_scope to...

...are now responsible for cleaning up myScope when you're done with it, by calling myScope.$destroy(). Javascript's garbage collection will not do this for you.

# code to run if the expression changes This watcher will continue to be called indefinitely unless you clean up after yourself: observer = -> # observe expression unsubscribe = $rootScope.$watch observer, (new...

api.rubyonrails.org

...and its methods is not suggested in the usual in-app workflow, as validations, callbacks, custom getters/setters etc. are ignored. However, for database-centered stuff like migrations, these fill the...

...but can be used as if it were an array of hashes. You may call #to_hash or #to_a on the result, which both will return a real Array...

handle_unverified_request When Rails gets a request with wrong/missing CSRF-Token, it calls ApplicationController#handle_unverified_request and continues processing the request!. Per default, the method only resets...

...the session id when logging in. After authentication, but before writing to the session, call reset_session. (Know this also wipes all data from the session – which might be ok...

nolanlawson.com

...of memory leaks are APIs like these: addEventListener. This is the most common one. Call removeEventListener to clean it up. setTimeout / setInterval. If you create a recurring timer (e.g. to...

...it’s used like setInterval – i.e., scheduling a new setTimeout inside of the setTimeout callback.) IntersectionObserver, ResizeObserver, MutationObserver, etc. These new-ish APIs are very convenient, but they are also...

...you try order yourself. If you are on Rails 2.3, be aware that find calls inside the block are implicitly scoped. This is fixed in Rails...

...an optional database kwarg (specified using the model representative). It may be added by calling the indexer method on the DatabaseCleaner module: DatabaseCleaner[:active_record, db: Foo]. The DatabaseCleaner gem...

...executes your statement for each of them. This means whenever you use this direct call in your code, you actually perform this on a list of cleaners, there is no...

makandra dev
content.pivotal.io

} } } }) }) Usage expect(actualValue).toBeAnything(...matcherArguments) When a matcher is invoked, Jasmine will call its compare() function with the actualValue, followed by any arguments passed to the matcher. It...

makandra dev
github.com

...seconds to 168 milliseconds. Maybe it's a good time to stop and call it a day. If the JSON you are trying to build is fairly simple, you could...

...that it already owns? By writing it to the disk (or into a so called "materialized view"). First, tell PostgreSQL with a migration what the contents of this view should...

makandra dev

...does happen, so it might seam confusing why the IDP logout is not working. Calling current_user within the after logout route results in an exception This might show up...

...saml_authenticatable (at least up to version 1.9.1) has a bug there: If you call current_user when a LogoutResponse is present as an URL param it fails to parse...

makandra dev
gist.github.com

Stacktrace frame [n] -- Moves to a frame in the n-th call stack You can use where to find out the numbers finish [n] -- Runs the program...

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...

...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...

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...

...handled before e.g. a page.refresh statement returns. That that this also applies to wrapped calls like accept_confirm { page.refresh }. Setting unhandled_prompt_behavior to a hash The W3C spec allows...

web.archive.org

...If you did this you will need to find the original branch point and call git rebase with a SHA1 revision. Your editor will open with a file like

digitalocean.com

...new node feature that automatically installs yarn (and pnpm) for you when it is called. It allows you to specify a desired yarn version inside package.json and makes sure the...

...Node.js starting from 14.19.0 and 16.9.0 but is disabled by default. To enable it, call: corepack enable The yarn command will be available afterwards. Note To start a new project...

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...

...updated_at_of_expensive_scope') fresh_when last_modified: updated_at The example above calls fresh_when without an object, so Rails will only set the Last-Modified header and...