Skip to content

Contracts and order of includes in the app #268

Description

@timuckun

I have a contract like this

 Contract Maybe[String], Maybe[String] => User
  def self.create_user
    validate_password(password, password_confirmation)
    hashed_password = DB["select crypt( ? , gen_salt('bf'));", password].first[:crypt]
    u = User.new(email: email)
    DB.transaction do
      u.save
      u.add_password_hash(hashed_password: hashed_password)
    end
  end

When the app includes the module this code is in I get an error message that says

uninitialized constant Svc::User (NameError)

So I tried ::User instead but that doesn't either. So it looks like I need to load all other classes first before I can use contracts that use them.

Is there a way to get around this?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions