relishapp.com

...are verified. Note that this is enabled by default when you are using rspec-rails along with verifying doubles. So if you really need to verify some dynamically defined methods...

...for storing time of day in the format hh:mm:ss, neither Ruby nor Rails themselves offer an elegant way to deal with day times. Time and DateTime both handle...

options: { search: 'window.toString() === \'[object GjsGlobal]\'', replace: 'window.toString() === \'[object Window]\'' } }] }) Fix for ESBuild / jsbundling-rails Add the package esbuild-plugin-text-replace to your package.json. Now add the following plugin...

...consume GBs of memory bringing down our servers. The solution Just use .preload instead. Rails will use separate queries to preload the data. This cannot lead to a cross product...

makandra dev
railsforzombies.org

Learning Rails for the first time should be fun, and Rails for Zombies allows you to get your feet wet without having to worry about configuration. You'll watch five...

...videos, each followed by exercises where you'll be programming Rails in your browser...

Rails 8 provides a new way of doing things after the current transaction, without defining a model "global" after_commit callback. def do_something update_column(:foo, "bar")

...update_column(:foo, "bar") ActiveRecord::Base.current_transaction.after_commit { send_email(foo: "bar") } ActiveRecord::Base.current_transaction.after_rollback { Rails.logger.warn("rollback") } # after_rollback is also supported end If you call current_transaction.after_commit in a nested...

If you get an error message like that you are missing the Aspell files a specific language:

sudo gem install rails --version="=1.2.3" rails _1.2.3_ new-project-folder

...changelog_path = File.expand_path('../CHANGELOG.md', __dir__) Ruby < 2.0 changelog_path = File.expand_path('../../CHANGELOG.md', __FILE__) Rails changelog_path = Rails.root.join('CHANGELOG.md...

robots.thoughtbot.com

Declare an enum attribute where the values map to integers in the database, but can be queried by name.

everydayrails.com

I recently had a need to demonstrate a data-heavy application to potential customers. Demonstrating the application with bogus numbers...

...only list versions that are allowed by your Gemfile requirements (e.g. does not show rails update to 6 if your Gemfile has the line gem 'rails', '~>5.2'). I also experienced...

makandra dev
unpoly.com

...events and origin all apply, including your own event listeners on the link and Rails' [data-method] and [data-confirm]. A link with [download] downloads its file, and a link...

...attribute, like links and forms do. It is an alias of [up-confirm], so Rails helpers like link_to or button_to work without changes. If your app handles [data...

...loads a new page. The browser does almost nothing but display. This is how Rails works out of the box: simple, robust, fast to build, easy to test with a...

...opens overlays, keeps scroll positions. Libraries in this family: Unpoly (our choice), Hotwire/Turbo (the Rails default), htmx. You keep the MPA's simplicity — one source of truth on the server...

...agent can't infer from the code: the test command, conventions that differ from Rails defaults, gotchas. It is not the place for things the agent already does right, or...

...stack isn't the default one, and an agent reaches for the default (Our Rails stack, and why it isn't Omakase). Judging the design. Whether this is simple, whether...

makandra dev

...query -> query embedding -> kNN search -> ranked pages | +--------------------------------------------------------------------+ See: How to add RAG to your Rails application Full-text keyword search (BM25) Full-text search splits each document into tokens (words...

...calls in local and CI tests. See also How to add RAG to your Rails application: vector search end-to-end. You don't need a vector database to build...

...accidentally translates the query. It might be a good idea to cache the result (Rails.cache) for some time so a page reload doesn't re-call the LLM. Authorize the...

...to Hybrid search for the trade-offs, or How to add RAG to your Rails application to get started on the vector branch...

justinfrench.com

If you’re testing the behavior of deprecated code in your Ruby project, the warning messages littered throughout your spec...

gist.github.com

The differences are subtle. You probably want to use Time, except when you want to use DateTime. See the attached...

...you UTC objects whose to_s(:db) may not convert properly. Legacy behavior in Rails 2.3 It's been briefly mentioned in the random list of ActiveSupport goodies, but please...

...remember to always use Time.current instead of Time.now, etc. Why? Because of the way Rails and MySQL deal with time zones you would need to take care to use Time.zone.now...

sudo apt-get install unzip rake rails:freeze:edge RELEASE...

...few examples, where you configure some library via a block. One example is the Rails configuration: Rails.application.configure do |config| config.enable_reloading = false end This card describes a simple example on...

...You can use ActiveSupport::Configurable instead of the Configuration class. When you are using Rails with Zeitwerk and the code for e.g. FooClient lives in a folder, that is loaded...

...MySQL or PostgreSQL. Implementation examples are for the ActiveRecord ORM used with Ruby on Rails, but the techniques can be implemented in any language or framework. We will be using...

...Always convert to a symbol, otherwise you'll have all kinds of fun. Newer rails / activerecord (at least 5.2) will throw an association names must be a Symbol (ArgumentError) error...