What can make the dependent: :nullify option fail with a ForeignKeyError on an ActiveRecord has_one relationship?

There are not two records referring to the same parent. The relationship works on a fresh app. It works in the tests. It works if I change the relationship to has_many. The code works in the debugger console that pops up in the browser when the same code raises an error within the controller action. WTF?

Enumerable#tally in Ruby 2.7 is cool, but I wish it took a block.

[1, 2, 3, 'string', 'str', CustomClass.new].tally(&:class)
=> {Integer=>3, String=>2, CustomClass=>1}

I saw some discussion for a :tally_by method to do this, but I don't see why :tally can't just take an optional block like :sum does.

I keep in my room a chunk of monocrystalline silicon with googley eyes on it just to remind me of the folly of teaching rocks to think

Today I upgraded a Rails app to Ruby 2.7.0 with no apparent issues. I was a little surprised at that, given the changes to keyword arguments, but the only warnings I saw appeared to be triggered by Rails itself, not by my app code, and they were just deprecation warnings.

(I've just seen a really interesting panel on Fairytale retellings at #Dublin2019, where The Beauty and the Beast was referenced a lot.)

Show thread

Now that there's a release candidate out, I upgraded my personal app to Rails 6. It took me a long time, lots of problems between the new Zeitwerk autoloader and the CMS I use (which is a Rails engine).

Is it weird that the most thoroughly tested portion of my music school administration app is the band name generator?

I need a printer recommendation. Details at this link, but replies here are appreciated as well.

dev.to/briankephart/mac-users-

Me: How do I work with currency?

Ruby: Just use BigDecimal.

JS: Deal with floating point math edge cases on every operation you do, forever.

Currently freezing in KC, where I'm jealous of all the folks at in LA.

BTW, does anyone know of a justification for Safari's truly pathetic support for form input types? It seems like Apple usually has a reason for stuff like this, even if it's a bad one. Also, this image upload didn't work in Brave 😦

Show thread

I downloaded Brave browser yesterday. It seems to work pretty well, although Hulu doesn't like it. It has the highest score on html5test.com/ of any browser I have, including Chrome, Firefox, Safari, and Opera.

@brian_kephart infosec stuff, data mining, ETL, everyday scripting. Ruby wasn't always the best option for these things, but as more non-web-dev gems were published things became better.

@brian_kephart I first used as a language to control and glue together some C++ code I was writing to simulate insect construction behaviours

@brian_kephart I had never heard of Ruby until I bought RPG Maker VX Ace in 2011. After using it in that program, I fell in love. I still haven't used Rails to this day (not that I'm avoiding it, I just haven't had a reason to yet)

Why do people always assume the only thing using ruby is web apps. There are several admin tools and security tools that use it as well.

Show more
Ruby.social

A Mastodon instance for Rubyists & friends