...card about using it already. This card explains why you want to use it. Read on for details. Deep dive Okay, so the example above has at least one obvious...

...Universe::World::Earth.table_name_prefix or if you even define it. It's not read at all. Here is why (follow links for a better understanding): An ActiveRecord class will...

makandra dev

let isButtonActive = $button.is('.active') // Native let button = document.querySelector('button') let isButtonActive = button.matches('.active') Read and write attributes // jQuery let name = $element.attr('name') $element.attr('name', 'new-name') // Native

...element.getAttribute('name') element.setAttribute('name', 'new-name')

...but you probably want to work with properties. Read and write properties (!) // jQuery let value = $input.prop('value') $element.prop('value', 'foo@bar.com') // Native let name = input.name...

makandra dev
github.com

...below can also applied in those cases, but they tend to result in less readable code. Let's see how we can get that thing 232 times faster..

drop_table :locks end end # spec/models/lock_spec.rb describe Lock, '.acquire' do before :each do @reader, @writer = IO.pipe end def fork_with_new_connection config = ActiveRecord::Base.remove_connection fork do

...the same lock' do (1..20).each do |i| fork_with_new_connection do @reader.close ActiveRecord::Base.connection.reconnect! Lock.acquire('lock') do @writer.puts "Started: #{i}" sleep 0.01 @writer.puts "Finished: #{i}" end @writer.close...

...use the expand_path method with either the constant __FILE__ or the method __dir__. Read this card for more information about __FILE__ and __dir__. Example Structure: . ├── bin │   ├── format_changelog ├── CHANGELOG.md...

...default property descriptor, use Object.defineProperty(object, key, descriptor). Let's use that to define a read-only property user.name: let user = {} Object.defineProperty(user, 'name', { value: 'Max', writable: false }) user.name // => 'Max...

Attribute Effect get A function that is called when the property is read ("getter") set A function that is called when the property is written ("Setter")

...of scope chaining. end end Explanation Note a couple of things: Every controller action reads or changes a single model. Even if an update involves multiple models,

...Standard implementation (with caching) We can improve the performance of our controllers by having reading actions (#show, #index) set ETag and Last-Modified response headers using #fresh_when

makandra dev

...Ruby will fall back on the method definition in the class itself. You can read more about that in Henning's card How Ruby method lookup works or in the...

...class in a much more convenient way than using alias_method_chain. You can read more about this here. As prepended modules should thus overwrite the existing method definition in...

...that using request.cookies and response.cookies is not recommend by RSpec anymore as can be read in the documentation link above. Model specs Whenever you have to use the same cookie...

...and write solid unit tests. Beware that your class will not be able to read the cookies, since they are only available within the controller and view context. Because of...

...is intended to give you an introduction to this emerging aspect of web development. Read this introductory performance study on Pinterest by Smashing Magazine. Frame Budget Most screens have a...

...box.offsetHeight); // Forces the browser to re-render *now* } Verdict: Make sure you always first read, then write style-relevant values. How to debug: Chrome shows warning icons in the event...

makandra dev

...not very future-proof: It breaks the ESM spec that demands imported modules to be read-only. It only works in some versions of Webpack (tested on Webpacker 5.4 with...

...when dependencies need approval (it is also the output of the failing licenses spec): Read on to learn what to do about the output. All decisions are written to doc/dependency_decisions.yml...

...to detect it manually. Check if current versions sport a license. Check package.json, composer.json, README. Once you know the license, tell LicenseFinder with bundle exec license_finder licenses add $DEPENDENCY...

...you think that wrapping transfer_money in a transaction would help, you should re-read this article from the top. What you should do instead is to wrap critical code...

...general suggestions. Before you start, talk to someone who has done it before, and read the following hints: Understand the old system Before any technical considerations, you need to understand...

...only available from Rails 8. There are cases where it might be fine to read directly, like: # Okay User.find(params[:id]) This still relies on params[:id] existing, so your...

...url_for(params.to_unsafe_h)` We have an extra card on this topic. Further reading It's also worth to read Rails: Using require and permit for attributes when configuring...

By default, Rails views escape HTML in any strings you insert. If you want to insert HTML verbatim, you need...

...only hides visually, not technically: the element is still focusable and visible to screen readers. So, how can we fade an element while maintaining accessibility? Enter visibility. It also hides...

...visibility, the hidden element is truly hidden and neither focusable nor visible to screen readers. Alternatives If you're starting your transition from JavaScript, you can give the element the...

If required, add more feature files in the same manner. From these, the reader should understand everything to know about the new feature you're building.

...examples you can think of:

it ' ' it ' ' it '...' end From these, the reader should understand everything to know about that method. When you're done listing examples, start...

...are three examples how you can avoid polluting the global namespace. You can also read the Rubocop docs on LeakyConstantDeclaration about this topic. When would I need this?

ruby-doc.org

...change that index node. In some cases it might also be convenient to just read/write the lock file first and update the other file afterwards or vice versa, such that...

The method You can define the following method to lock a file from read and write access by methods like File.open and File.read. def exclusively_locked_access begin

...In the row below the dev tool tabs, there's a throttling dropdown which reads "Online" by default. Inside the dropdown, you will find a few presets and an option...

...the row right below the dev tool tabs you will find an option which reads "No throttling" by default. Pick one of the presets available there. Most processes that aren...

...have just merged the branch \"$merged_branch_name\" into \"$branch_name\". " # Ask the question read -p "> Do you want to push \"$branch_name\" + delete the \"$merged_branch_name\" branch? (y/N...

...script like this: # This class will be specced # To simplify this, it should not read input class YourScript # Methods offering functionality end unless Rails.env.test? script = YourScript.new # All interactivity (i.e. reading...

expect { subject.print_summary }.to output(/success/).to_stdout end end Further reading Maintaining custom application tasks in Rails

When requests arrive at the application servers simultaneously, weird things can happen. Sometimes, this can also happen if a user...