Here is how to disable it, or how to add it to your Rails console. Welcome banner Modern versions of irb show a pretty banner which prints

...have one yet) and add: IRB.conf[:SHOW_BANNER] = false How to enable for the Rails console You like the banner and want to see it for a rails console as...

...end-to-end test for every small requirement. After we integrated Jasmine into a Rails app we often add an E2E test that opens that Jasmine runner and expects all...

If you're using a Redis cache in Rails (e.g. :redis_cache_store), it's possible to configure additional parameters for your Redis connection. Example config for Rails 7.2

...too low value for timeouts can make your cache timeout too often. Note that Rails explicitly sets connect_timeout, read_timeout and write_timeout, which means that only configuring timeout...

When your Rails application is using Redis as its cache store, this is how you can list existing keys: Check: Rails.cache should return an ActiveSupport::Cache::RedisCacheStore. Rails.cache.redis.with(&:keys) lists...

Icon fonts like Font Awesome are infinitely scalable, look great on high-DPI displays and will give your app a...

Rails' default logger prefixes each log entry with timestamp and tags (like request ID). For multi-line entries, only the first line is prefixed which can give you a hard...

...time when grepping logs. Example Rails.logger.info(<<~TEXT) Response from example.com: Status: 200 Body: It works! TEXT With that, the following is written to your log file.

If you are using the routing-filter gem in your Rails 7.1 app for managing URL segments for locales or suffixes, you will notice that the filters do no longer...

...and the necessary parameters are no longer extracted. That is because routing-filter patches Rails' find_routes-method to get the current path and apply its defined filters on it...

RSpec Rails can automatically mix in different behaviors to your tests based on their type tag, for example enabling you to call get and post in specs with the tag...

...a good default to add a unique index on the foreign key when using Rails’ has_one relationship. This ensures the database enforces the 1:1 constraint and raises an...

makandra Curriculum

Read the Rails Guide about Active Record migrations Understand why we never use models in migrations. Checkout the repository Project Hero and read through some migrations in db/migrate. Find...

...files in the db/migrate folder. Read and understand How to write complex migrations in Rails Discuss with your mentor Instead of migrations, could we simply log into the production server...

When using Rails credentials, you will edit the encrypted credentials for staging or production environments from time to time. To do that you need the secret key which should only...

...to live in :shared_path/config/credentials/:stage.key. If you have a single master.key (e.g. on Rails < 7.2), edit the Capistrano task to find the key at :shared_path/config/master.key instead. Usage

This cards describes an example with a Github Client on how to keep your Rails application more maintainable by extracting domain independent code from the app/models folder to the lib...

...scenarios and not limited to API clients. Example Let's say we have a Rails application that synchronizes its users with the Github API: . └── app └── models ├── user │   ├── github_client.rb │   └── sychronizer.rb └── user.rb...

Rails 7.1 added a new method Rails.env.local?. If you want to stub the Rails env correctly, use ActiveSupport::EnvironmentInquirer like this: # check if the value of stubbed_env is valid...

...allow(Rails).to receive(:env).and_return(ActiveSupport::EnvironmentInquirer.new(stubbed_env.to_s...

You can improve your LIKE / ILIKE search queries in PostgreSQL by adding a GIN index with an operate class ("opclass...

github.com

...This is arguably a good idea. As a workaround, use stub_const in your Rails specs like this: stub_const "#{SomeClass}::CONST", 'test' This will invoke Rails' autoloading and fix...

...to your DB schema. Ignore the column With ignored_columns you can prevent your Rails models from generating accessor methods for these columns: class User < ApplicationRecord self.ignored_columns += [:legacy_field...

#pluck is commonly used as a performant way to retain single database values from an ActiveRecord::Relation Book.pluck(:title, :price...

stackoverflow.com

To reload a single-item association in Rails 5+, call #reload_ : post.reload_author In older Railses you can say post.author(true...

...a cookie's "secure" flag do? Is it still relevant with HSTS? Look at Rails' API for managing cookies How do you set and delete cookies? What are signed cookies...

What are encrypted cookies and how do they work? Learn about Rails sessions (which are not the same as 'session cookies') Learn about the SameSite cookie attribute...

When putting phone numbers into web pages, you should use tel: links so smartphone users can click those numbers to...

After an upgrade to rails 7 I noticed that async reindexing jobs of Searchkick were failing for Model.reindex(mode: :async, wait: true): /home/a_user/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/searchkick-5.3.1/lib/searchkick/relation_indexer.rb:142:in `block in batch_job': undefined...

We are using assignable_values for managing enum values in Rails. Nevertheless Rails is adding more support for enum attributes, allowing to have a closer look at the current feature...

...to our still preferred option assignable_values. Active Record enum attribute interface By default Rails is mapping enum attributes to integers: class Conversation < ActiveRecord::Base enum :status, [ :active, :archived ]

makandra dev

...ALLOW_REMOTE_DATABASE_URL: 'true' DATABASE_URL: postgres://postgres:postgres@localhost:5432/test PGTZ: 'Europe/Berlin' RAILS_ENV: test TZ: 'Europe/Berlin' strategy: matrix: partition: [ 0, 1, 2, 3 ] # Keep in sync with...

...uses: actions/checkout@v4 - uses: ./.github/actions/setup-node - uses: ./.github/actions/setup-ruby - name: Setup database schema run: bundle exec rails db:create db:schema:load - name: Precompile assets run: bundle exec rails assets:precompile

makandra dev

...for consumption in browsers. Webpacker is a wrapper around webpack that handles integration with Rails. This is a short introduction. Installation If you haven't already, you need to install...

...x is still current! in your Gemfile. Run bundle install Finally, run bundle exec rails webpacker:install Alternatively, you can add webpacker from the start when creating a new Rails...