elsoul / souls

🚧Deprecated. Moved to Skeet https://skeet.dev/ 🚧🕺 SOULs 💃 Build Serverless Apps faster like Rails. Powered by Ruby GraphQL, Active Record, RSpec, RuboCop, and Google Cloud.
https://skeet.dev
Apache License 2.0
332 stars 4 forks source link

Working with modules #323

Closed antarr closed 2 years ago

antarr commented 2 years ago

I'm trying to move as much of my existing rails application to souls. I'm running into errors when dealing with modules/concerns.

I was getting an error with

module Legiscan
  require 'legiscan/error'
  require 'legiscan/request'
  require 'legiscan/push'

Was able to fix it by moving those class definitions in the same file

But now I'm getting an error with my concerns. I'm getting this error

NameError: uninitialized constant Voter

  include Voter

in my model

class User < ApplicationRecord
  include Voter
  include Follower
  include Verifiable
  include Devise::JWT::RevocationStrategies::JTIMatcher

How can I import modules into my models?

POPPIN-FUMI commented 2 years ago

when did you get this error? souls check? or souls s?

antarr commented 2 years ago

When running migrations souls db migration

POPPIN-FUMI commented 2 years ago

did you add require at app.rb ? souls is using zeitwerk, you can add your modules at app.rb !

antarr commented 2 years ago

@POPPIN-FUMI Thanks that was it. Had to add loader.push_dir("#{Dir.pwd}/app/models/concerns")

POPPIN-FUMI commented 2 years ago

@antarr Cool! I'm glad to hear that! Happy coding!