Ruby and Ruby on Rails tricks from, dot files, operators, bundling, StimulusJS and more.

izzy's playlists!
noise dept.
occasionally subtle
One Nice Bug Per Day
Peter Solarz

Kaledo Art
cherry valley forever

blake kathryn

oozey mess
DEAR READER
Claire Keane
ojovivo
RMH
KIROKAZE
Show & Tell
Misplaced Lens Cap
Sweet Seals For You, Always
he wasn't even looking at me and he found me

Andulka

❣ Chile in a Photography ❣

seen from Canada
seen from United States
seen from United States

seen from United States

seen from United States
seen from United States
seen from United States

seen from United States
seen from Canada
seen from Spain
seen from Malaysia
seen from Germany
seen from United Arab Emirates
seen from United States

seen from China

seen from United Kingdom
seen from United States

seen from Spain

seen from Canada
seen from Malaysia
@rubydailystream
Ruby and Ruby on Rails tricks from, dot files, operators, bundling, StimulusJS and more.
In this episode, we look into using Push Notifications within our Rails application and then using ActionCable to broadcast Push Notifications to the user.
render_async allows you to load partials by reacting with a specific HTML element.
If you want your partial to be loaded when a button is clicked or hovered over, you can specify that in new render_async 2.1.1 version
Also, you can start and stop polling a controller action with render_async using the new toggle feature.
When database tables get large, things can slow down significantly. In this episode, we look at a few things which helps keep databases performant and the client side responsive.
Runbook is a Ruby gem that provides a high-level language for gradually automating system operations such as on-call playbooks, system maintenance, and code releases.
Finding time-consuming database queries for ActiveRecord-based Rails Apps - kirillshevch/query_track
New week new bug to hunt down! A day after our last deployment at work, a new type of error started rising like a great wave. Random SQL update queries started failing at random with the following error: ActiveRecord::StatementInvalid: Mysql2::Error: Lock wait timeout exceeded; try restarting transaction: UPDATE users SET ...
Dragon Ruby is toolchain that allows developers the ability to build apps and games in Ruby. Giveaway - Follow @driftingruby and retweet this to enter to win a free DragonRuby license. Event will end by August 1st, 2019.
https://twitter.com/DriftingRuby/status/1148074922826194949
Ed Toro speaks to his experience at bootcamps from a teacher's perspective. We gain a different perspective of what bootcamps are like. Ed shares valuable information whether you're considering getting into coding or currently at a bootcamp.
FactoryTrace helps you to cleanup unused factories (by @EvgeniyDemin)
If you write tests for your project and use FactoryBot to generate test data then gem FactoryTrace can help you to maintain your factories and traits in the actual state.
What it does?
When you execute your tests gem traces usage of factories and in the end outputs a report.
$ FB_TRACE=1 rspec total number of unique used factories & traits: 3 total number of unique unused factories & traits: 2 unused global trait with_email unused factory admin
Integration
For RSpec, it's enough to just install the gem and it can be used. For any other testing framework, simple do these manipulations:
# add it to the beginning of your tests execution FactoryTrace.start # add it to the end of your tests execution FactoryTrace.stop
Parallel/Partial execution
Sometimes, if tests take long time to execute, we run them in parallel process by partials, and to make data of unused factories correct we need to process usage from all runners.
You can do it in the following way:
# first partial FB_TRACE=trace_only FB_TRACE_FILE=fb_trace_result1.txt bundle exec rspec spec/first_spec.rb # second partial (it can be more) FB_TRACE=trace_only FB_TRACE_FILE=fb_trace_result2.txt bundle exec rspec spec/second_spec.rb # grouping and processing bundle exec factory_trace fb_trace_result1.txt fb_trace_result2.txt
How it works?
Thanks to the implementation of FactoryBot with using ActiveSupport::Notifications we can easily add a callback, when a factory was used:
ActiveSupport::Notifications.subscribe('factory_bot.run_factory') do |_name, _start, _finish, _id, payload| name = payload[:name] traits = payload[:traits] storage[name] ||= Set.new storage[name] |= traits end
And after gathering all the information, we can find all unused factories and traits.
Try it yourself and share your opinion. Any contribution is welcome! Thank you for your time!
More tools
DatabaseConsistency - help you to maintain consistency between your database schema and models definitions.
DatabaseValidations - provides two one-line replacement helpers: db_belongs_to and validates_db_uniqueness_of with better performance and consistency.
P.S. Original post was made by me on reddit.
Sign In with Apple implementation for Ruby and OmniAuth
Using Rails UJS, we create an interactive row editing solution without using any kind of Javascript frameworks.
ActiveRecord force destroy records with all related associations.
Riaz talks about his experience with organizing and hosting the Atlanta Ruby Users Group meetup. We discuss sponsors, hidden costs of hosting meetups and general tips for guests.