SpinaCMS/Spina

Rails 7.1: in `serialize': missing keyword: :coder (ArgumentError)

Closed this issue · 5 comments

I tried to install Spina 2.15.0 on a fresh Rails 7.1.0.alpha app generated with rails new myapp --main --css=tailwind --database=postgresql as follows:

bundle add spina
rails active_storage:install
rails g spina:install

But that last command generates this error after DB migration:

/opt/homebrew/lib/ruby/gems/3.2.0/bundler/gems/rails-455e922b49c5/activerecord/lib/active_record/attribute_methods/serialization.rb:208:in `serialize': missing keyword: :coder If no default coder is configured, a coder must be provided to `serialize`. (ArgumentError)
Stack trace
            raise ArgumentError, <<~MSG.squish
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/spina-2.15.0/app/models/spina/account.rb:8:in `<class:Account>'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/spina-2.15.0/app/models/spina/account.rb:2:in `<module:Spina>'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/spina-2.15.0/app/models/spina/account.rb:1:in `<main>'
        from <internal:/opt/homebrew/Cellar/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from <internal:/opt/homebrew/Cellar/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb:30:in `require'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/spina-2.15.0/lib/generators/spina/install_generator.rb:35:in `create_account'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:134:in `block in invoke_all'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:134:in `each'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:134:in `map'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:134:in `invoke_all'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/group.rb:232:in `dispatch'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
        from /opt/homebrew/lib/ruby/gems/3.2.0/bundler/gems/rails-455e922b49c5/railties/lib/rails/generators.rb:261:in `invoke'
        from /opt/homebrew/lib/ruby/gems/3.2.0/bundler/gems/rails-455e922b49c5/railties/lib/rails/commands/generate/generate_command.rb:26:in `perform'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
        from /opt/homebrew/lib/ruby/gems/3.2.0/bundler/gems/rails-455e922b49c5/railties/lib/rails/command/base.rb:179:in `invoke_command'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
        from /opt/homebrew/lib/ruby/gems/3.2.0/bundler/gems/rails-455e922b49c5/railties/lib/rails/command/base.rb:74:in `perform'
        from /opt/homebrew/lib/ruby/gems/3.2.0/bundler/gems/rails-455e922b49c5/railties/lib/rails/command.rb:71:in `block in invoke'
        from /opt/homebrew/lib/ruby/gems/3.2.0/bundler/gems/rails-455e922b49c5/railties/lib/rails/command.rb:149:in `with_argv'
        from /opt/homebrew/lib/ruby/gems/3.2.0/bundler/gems/rails-455e922b49c5/railties/lib/rails/command.rb:69:in `invoke'
        from /opt/homebrew/lib/ruby/gems/3.2.0/bundler/gems/rails-455e922b49c5/railties/lib/rails/commands.rb:18:in `<main>'
        from <internal:/opt/homebrew/Cellar/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from <internal:/opt/homebrew/Cellar/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from /opt/homebrew/lib/ruby/gems/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
        from bin/rails:4:in `<main>'

This is the line where the error is thrown:

serialize :preferences

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Same problem here with Rails 7.1.0. I am happy to provide further details, if necessary.

Generating a new app on Spina is currently not supported on Rails 7.1 and I havent had the time to look into this yet. @RandieM if you have more details, feel free to share!

Updated Spina to v2.17.0 with support for Rails 7.1!

Right when I was going to say that I've tried using JSON or YAML as coder in the Account model and it fixed the issue for me, I saw that you had just released a new gem version.

I've tried the new release and I can confirm that it works. Thanks a lot for the prompt fix!