Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Model with enum raises ArgumentError: wrong number of arguments (given 3, expected 1) #552

Open
rspeicher opened this issue Mar 21, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@rspeicher
Copy link

rspeicher commented Mar 21, 2023

Describe the bug:

I'm attempting to generate RBIs for the following model:

class TeamMember < ApplicationRecord
  ROLES = {
    unassigned: "unassigned",
    contractor: "contractor",
    employee: "employee"
  }.freeze

  enum :role, ROLES, default: :unassigned, suffix: true
end

But the following error gets raised:

main % be rails 'rails_rbi:models'
rails aborted!
ArgumentError: wrong number of arguments (given 3, expected 1)
/Users/rspeicher/.../app/models/team_member.rb:26:in `<class:TeamMember>'
/Users/rspeicher/.../app/models/team_member.rb:1:in `<main>'
Tasks: TOP => rails_rbi:models
(See full trace by running task with --trace)

The same error gets raised with a reduced enum like so:

enum :role, %i[foo bar]

Steps to reproduce:

  • Generate a model with an enum field
  • Run the rails_rbi:models task

Expected behavior:

RBIs for models are generated.

Versions:

  • Ruby: ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22]
  • Rails: Rails 7.0.4.3
  • Sorbet: Sorbet typechecker 0.5.10712 git dd4602e030832c930d0b413f31734a83708448f6 debug_symbols=true clean=1
  • Sorbet-Rails: sorbet-rails-0.7.34

This may be related to #479

@rspeicher rspeicher added the bug Something isn't working label Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant