Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devise's generated model code contains syntax errors #5756

Open
nathan-harvestwell opened this issue Jan 13, 2025 · 0 comments
Open

Devise's generated model code contains syntax errors #5756

nathan-harvestwell opened this issue Jan 13, 2025 · 0 comments

Comments

@nathan-harvestwell
Copy link

Environment

  • Ruby ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin22]
  • Rails Rails 7.2.2
  • Devise 4.9.4

Current behavior

Created a new Rails app for the first time in a long time. Added Devise, generated models and ran migrations successfully.

Expected behavior

A bootable app.

Actual behavior

The call to the devise method that was automatically inserted into my user.rb file throws syntax errors:

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :database_authenticatable :registerable
         :recoverable, :rememberable, :validatable

  enum :role, [:user, :admin, :superadmin]

  after_initialize :set_default_role, if: :new_record?

  # set default role to user  if not set
  def set_default_role
    self.role ||= :user
  end
end
% rails server
=> Booting Puma
=> Rails 7.2.2 application starting in development 
=> Run `bin/rails server --help` for more startup options
Exiting
/Users/myuser/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundled_gems.rb:74:in `require': --> /Users/myuser/dev/myorg/alfalfa/app/models/user.rb
expected a newline or semicolon after the statementcannot parse the expression
   1  class User < ApplicationRecord
>  4    devise :database_authenticatable :registerable
>  5           :recoverable, :rememberable, :validatable
>  7    enum :role, [:user, :admin, :superadmin]
  15  end

/Users/myuser/dev/myorg/alfalfa/app/models/user.rb:4: syntax error, unexpected ':', expecting `end' or dummy end (SyntaxError)
...ise :database_authenticatable :registerable
...                              ^
/Users/myuser/dev/myorg/alfalfa/app/models/user.rb:5: syntax error, unexpected ',', expecting `end' or dummy end
         :recoverable, :rememberable, :validatable
                     ^

Did I get some incompatible version mismatches somehow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant