Search code examples
ruby-on-rails

rails migration to version 7 still defaults to HTML


Having migrated rails from 6.1 to 7.0, forms or button_to are still processing as HTML
<%= button_to change_shops_for_analysis_promotions_path, method: :post, params: {shop_id: shop.id, toggle: 0}, data: { turbo: true } do %> is being logged as:
Processing by PromotionsController#change_shops_for_analysis as HTML

The upgrade instructions refer to framework defaults. Once the version was updated, application.rb was adjusted with config.load_defaults 7.0... In case of the major version 7 one would expect that this implies that TURBO_STREAM becomes the default processing mechanism.

However, that is not the observed case. How can the default processing be set to TURBO_STREAM then?

Gemfile:

gem 'rails', '~> 7.0', '>= 7.0.8.4'
gem "pg", "~> 1.1"
gem "puma", ">= 5.0"
gem "importmap-rails", "~> 2.0"
gem "turbo-rails"
gem "stimulus-rails"

Solution

  • The migration process from 6.1 to 7.0 of Rails is not obvious and it has a sequence that must be respected. These are not outlined in the Rails guide (as of this date), but can be concluded by reading the homePages on GitHub for the three tools.

    1. upgrade ruby, if necessary (I had no issues goint to 3.1.2,
    2. upgrade rails to 7.0,
    3. install importmaps (see github page for instruction). Subsequently,
    4. install turbo-rails (see github). Then,
    5. install stimulus (see github).

    Do each step sequentially, not together.