nerdculture.de is one of the many independent Mastodon servers you can use to participate in the fediverse.
Be excellent to each other, live humanism, no nazis, no hate speech. Not only for nerds, but the domain is somewhat cool. ;) No bots in general. Languages: DE, EN, FR, NL, ES, IT

Administered by:

Server stats:

1.2K
active users

#activerecord

2 posts2 participants0 posts today
Esparta :ruby:<p>Wide Models and Active Record custom validation contexts, by <span class="h-card" translate="no"><a href="https://ruby.social/@bensheldon" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>bensheldon</span></a></span></p><p><a href="https://island94.org/2025/04/wide-models-and-active-record-custom-validation-contexts" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">island94.org/2025/04/wide-mode</span><span class="invisible">ls-and-active-record-custom-validation-contexts</span></a></p><p>&gt; This post is a brief description of a pattern I use a lot using when building features in Ruby on Rails apps and that I think needed a name:</p><p>&gt; Wide Models have many attributes (columns in the database) that are updated in multiple places in the application, but not always all at once i.e. different forms will update different subsets of attributes on the same model.</p><p><a href="https://ruby.social/tags/ruby" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ruby</span></a> <a href="https://ruby.social/tags/ActiveRecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ActiveRecord</span></a></p>
Esparta :ruby:<p>How fast can an ActiveRecord SQL query run?, by Fritz Meissner<br><a href="https://thoughtbot.com/blog/how-fast-can-an-activerecord-sql-query-run" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">thoughtbot.com/blog/how-fast-c</span><span class="invisible">an-an-activerecord-sql-query-run</span></a></p><p>&gt; Your database monitoring (perhaps Amazon RDS performance insights, Skylight, or the <a href="https://ruby.social/tags/Postgres" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Postgres</span></a> pg_stat_activity view) is telling you that one particular query in your Rails app is causing heavy load. Unfortunately, it already seems pretty fast. What are the odds that you can get it to run any faster?</p><p><a href="https://ruby.social/tags/ruby" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ruby</span></a> <a href="https://ruby.social/tags/SQL" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>SQL</span></a> <a href="https://ruby.social/tags/ActiveRecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ActiveRecord</span></a></p>
Chetan Mittal<p>Integer Enums vs. String Enums in Rails: Which One Should You Use?</p><p>Discover whether to use integer or string enums in Ruby on Rails. Learn their differences and see real-world code examples.</p><p><a href="https://ruby.social/tags/Ruby" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Ruby</span></a> <a href="https://ruby.social/tags/RubyonRails" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>RubyonRails</span></a> <a href="https://ruby.social/tags/Enums" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Enums</span></a> <a href="https://ruby.social/tags/ActiveRecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ActiveRecord</span></a> </p><p><a href="https://blog.railsforgedev.com/integer-enums-vs-string-enums-rails-best-practices" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">blog.railsforgedev.com/integer</span><span class="invisible">-enums-vs-string-enums-rails-best-practices</span></a></p>
alexanderadam<p>It's always great to see <span class="h-card" translate="no"><a href="https://tu.social/@rosa" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>rosa</span></a></span> and she talked about her <a href="https://ruby.social/tags/SolidQueue" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>SolidQueue</span></a> implementation at <a href="https://ruby.social/tags/rubycommunityconference" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>rubycommunityconference</span></a> in <a href="https://ruby.social/tags/krakow" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>krakow</span></a>.</p><p>She also gave a shout-out to <span class="h-card" translate="no"><a href="https://ruby.social/@bensheldon" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>bensheldon</span></a></span>'s <a href="https://ruby.social/tags/goodjob" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>goodjob</span></a> and mentioned how <span class="h-card" translate="no"><a href="https://ruby.social/@getajobmike" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>getajobmike</span></a></span>'s <span class="h-card" translate="no"><a href="https://ruby.social/@sidekiq" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>sidekiq</span></a></span> is blazingly fast.</p><p><a href="https://ruby.social/tags/ruby" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ruby</span></a> <a href="https://ruby.social/tags/rails" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>rails</span></a> <a href="https://ruby.social/tags/queue" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>queue</span></a> <a href="https://ruby.social/tags/rubyonrails" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>rubyonrails</span></a> <a href="https://ruby.social/tags/activerecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>activerecord</span></a> <a href="https://ruby.social/tags/poland" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>poland</span></a> <a href="https://ruby.social/tags/37signals" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>37signals</span></a> <a href="https://ruby.social/tags/backgroundprocessing" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>backgroundprocessing</span></a> <a href="https://ruby.social/tags/backgroundprocesses" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>backgroundprocesses</span></a> <a href="https://ruby.social/tags/sidekiq" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>sidekiq</span></a></p>
Honeybadger.io<p>New from Julie Kent:</p><p>Imaging you have a Rails endpoint that has slow queries AND performs third-party HTTP requests. With Rails async queries, you can perform these operations in parallel—without being an expert in multithreading. 🚀</p><p><a href="https://www.honeybadger.io/blog/rails-async-queries/?utm_source=mastodon&amp;utm_medium=social" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://www.</span><span class="ellipsis">honeybadger.io/blog/rails-asyn</span><span class="invisible">c-queries/?utm_source=mastodon&amp;utm_medium=social</span></a></p><p><a href="https://honeybadger.social/tags/Ruby" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Ruby</span></a> <a href="https://honeybadger.social/tags/RubyOnRails" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>RubyOnRails</span></a> <a href="https://honeybadger.social/tags/ActiveRecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ActiveRecord</span></a> <a href="https://honeybadger.social/tags/Performance" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Performance</span></a> <a href="https://honeybadger.social/tags/Programming" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Programming</span></a></p>
Clairement crevée<p>ok, <a href="https://social.sitedethib.com/tags/Rails" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Rails</span></a> <a href="https://social.sitedethib.com/tags/ActiveRecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ActiveRecord</span></a> thing:</p><p>Some people upgrading to Mastodon 4.3.0 seem to have messed up their migration relating to Active Record Encryption, by changing the secrets at some point after they first used them.</p><p>Of course since the keys have changed, the encrypted columns are irrevocably lost, and nothing can be done about that. But is there something we can do to lessen the risks of people running into that by catching the issue earlier?</p><p>Also, even overwriting those attributes is not possible in normal Rails code because <code>save!</code>ing will call <code>attribute_changed?</code> which will in turn try to decrypt the value to compare it, and raise an exception. Is there a way we can better handle columns that fail to decrypt when we are just interested in overriding them?</p>
Esparta :ruby:<p>Eradicating N+1s: The Two-phase Data Load and Render Pattern in Go, by <span class="h-card" translate="no"><a href="https://mastodon.social/@brandur" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>brandur</span></a></span> </p><p>&gt; Using a two-phase data load and render pattern to prevent N+1 queries in a generalized way. Especially useful in Go, but applicable in any language.</p><p><a href="https://ruby.social/tags/golang" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>golang</span></a> <a href="https://ruby.social/tags/ActiveRecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ActiveRecord</span></a> <a href="https://ruby.social/tags/ruby" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ruby</span></a></p>
postmodern<p>Why is ActiveRecord &gt; 7.1 still broken on JRuby? Appears activerecord-jdbc-adapter still hasn't been updated.<br><a href="https://github.com/ronin-rb/ronin-db-activerecord/actions/runs/9264533331/job/25484805001" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">github.com/ronin-rb/ronin-db-a</span><span class="invisible">ctiverecord/actions/runs/9264533331/job/25484805001</span></a><br><a href="https://ruby.social/tags/activerecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>activerecord</span></a> <a href="https://ruby.social/tags/jruby" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>jruby</span></a></p>
postmodern<p>How do you safely close the sqlite3 database file when using ActiveRecord in a Sinatra app? Doling a Ctrl^C results in the sqlite3 lock files being left behind.<br><a href="https://ruby.social/tags/sinatra" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>sinatra</span></a> <a href="https://ruby.social/tags/activerecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>activerecord</span></a></p>
postmodern<p>What do people prefer for ensuring that ActiveRecord connections get freed (in a Sinatra app)?<br><a href="https://ruby.social/tags/activerecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>activerecord</span></a> <a href="https://ruby.social/tags/sidekiq" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>sidekiq</span></a> <a href="https://ruby.social/tags/sinatra" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>sinatra</span></a></p>
postmodern<p>Why do I keep getting this error with ActiveRecord in this Sinatra+Sidekiq app:</p><p>could not obtain a connection from the pool within 5.000 seconds (waited 5.000 seconds); all pooled connections were in use</p><p>I'm already passing `pool: 4` to `ActiveRecord::Base.establish_connect(...)` to set the connection pool size, which is what Google/StackOverflow recommends, but it's still randomly occurring.<br><a href="https://ruby.social/tags/activerecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>activerecord</span></a></p>
Steven Harman<p>Another day, another <a href="https://ruby.social/tags/ActiveRecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ActiveRecord</span></a> feature proposal from our team. 😆</p><p>This one would allow a middleware-esque design for altering the behavior/configuration of DB transactions.</p><p><a href="https://discuss.rubyonrails.org/t/proposal-activerecord-transaction-middleware/85517" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">discuss.rubyonrails.org/t/prop</span><span class="invisible">osal-activerecord-transaction-middleware/85517</span></a></p><p><a href="https://ruby.social/tags/Rails" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Rails</span></a></p>
Steven Harman<p>A neat idea for preventing <a href="https://ruby.social/tags/ActiveRecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ActiveRecord</span></a> DB access within the scope of a block, from another of my too smart coworkers. <a href="https://discuss.rubyonrails.org/t/proposal-prevent-activerecord-access/85322" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">discuss.rubyonrails.org/t/prop</span><span class="invisible">osal-prevent-activerecord-access/85322</span></a></p><p><a href="https://ruby.social/tags/Rails" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Rails</span></a></p>
Jack of all trades<p>ActiveRecord's callback hell is worse than JavaScript's callback hell.</p><p>Prove me wrong.</p><p><a href="https://mas.to/tags/rails" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>rails</span></a> <a href="https://mas.to/tags/ruby" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ruby</span></a> <a href="https://mas.to/tags/callbacks" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>callbacks</span></a> <a href="https://mas.to/tags/CallbackHell" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>CallbackHell</span></a> <a href="https://mas.to/tags/ActiveRecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ActiveRecord</span></a> <a href="https://mas.to/tags/javascript" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>javascript</span></a></p>
postmodern<p>Lazy ActiveRecord: can you use query class-methods defined in another model from within where() statements when doing deep joins() from a different model?</p><p>class Bar &lt; ActiveRecord::Base<br> def self.with_baz(value)<br> ...<br> end<br>end</p><p>class Thing &lt; ActiveRecord::Base<br> def self.bars_with_baz(value)<br> joins(foo: [:bar]).where(<br> foo: {<br> bar: {with_baz: value}<br> }<br> )<br> end<br>end</p><p><a href="https://ruby.social/tags/activerecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>activerecord</span></a></p>
Florian Posdziech<p>Jeder im Team hat so seine eigenen Kniffe und Aliase und so. Mein liebstes ist mein `migrate`-Kommando, das erstmal die Datenbank-Migration ausführt, dann zurückrollt und dann nochmal macht.</p><p>So finde ich regelmäßig Migrationen, die nicht ordentlich zurückgerollt werden können. Zu dem Zeitpunkt sind die zwar schon deployed, werden aber natürlich trotzdem noch gefixt.</p><p>Bin mir nicht sicher, ob die Kollegen mich dafür feiern oder hassen. 🙈 </p><p><a href="https://chaos.social/tags/ruby" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ruby</span></a> <a href="https://chaos.social/tags/rails" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>rails</span></a> <a href="https://chaos.social/tags/activerecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>activerecord</span></a></p>
postmodern<p>Why does ActiveRecord enum recommend using this calling convention:</p><p> enum colname: [...], ...</p><p>and not:</p><p> enum :colname, [...], ...</p><p>Apparently both can be used.<br><a href="https://api.rubyonrails.org/v5.1/classes/ActiveRecord/Enum.html" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">api.rubyonrails.org/v5.1/class</span><span class="invisible">es/ActiveRecord/Enum.html</span></a><br><a href="https://ruby.social/tags/activerecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>activerecord</span></a></p>
postmodern<p>If you were using ActiveRecord enums to store acronym names in a database (ex: POST, TCP, RSA, etc). Would you expect them to be stored as UPPERCASE or lowercase? I want to do the polite thing for anyone who might want to try and directly interact with the database, sans ActiveRecord.<br><a href="https://ruby.social/tags/activerecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>activerecord</span></a></p>
Larry Garfield<p>An excellent if long writeup about the failures of <a href="https://phpc.social/tags/ActiveRecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ActiveRecord</span></a>. Which is also one of the reasons I am so vocal about the fundamental problems of <a href="https://phpc.social/tags/Laravel" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Laravel</span></a>/#Eloquent, as it's a particularly messy Active Record implementation. </p><p><a href="https://shawnmc.cool/active-record-how-we-got-persistence-perfectly-wrong" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">shawnmc.cool/active-record-how</span><span class="invisible">-we-got-persistence-perfectly-wrong</span></a></p><p><a href="https://phpc.social/tags/PHP" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>PHP</span></a></p>
postmodern<p>Ooooooh! You can do `self.inheritence_column = nil`! That is much cleaner than `self.inheritance_column = 'disable-sti-so-i-can-use-the-type-column'`.<br><a href="https://ruby.social/tags/activerecord" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>activerecord</span></a></p>