Skip to content

[bug] ContactCompany validator references undefined method must_belong_to_same_account #6

@dvlexp

Description

@dvlexp

The ContactCompany model declares validate :must_belong_to_same_account but the method is
never defined in the class. Any attempt to create a
contact ↔ company link crashes with NoMethodError
before the record is even saved.

Affected file

app/models/contact_company.rb

validate :must_belong_to_same_account
# ...but no def must_belong_to_same_account anywhere
 in the class or included modules

Reproduction

Single-tenant community install, fresh.

curl -X POST "https://api-crm.example.com/api/v1/con
tacts/<person_uuid>/companies" \
  -H "api_access_token: ..." \
  -H "Content-Type: application/json" \
  -d '{"company_id":"<company_uuid>"}'

Or via Rails console:

Contacts::LinkCompanyService.new(contact:
Contact.find(<person>), company:
Contact.find(<company>)).perform
# => {success: false, error: "undefined method
'must_belong_to_same_account' for an instance of
ContactCompany"}

Expected

200 on success, 422 on validation failure (e.g.
already linked, type mismatch).

Actual

500 Internal Server Error on every single request
— the whole contact_companies API is effectively
dead.

Proposed fix

Since the community edition is single-tenant, the
method is not needed. Two options:

  1. Remove the validate :must_belong_to_same_account declaration
  2. Define the method as a no-op (keeps the code
    structure for a future SaaS port)
private

def must_belong_to_same_account
  # single-tenant — no-op
end

Happy to open a PR.

Version

Image evoapicloud/evo-ai-crm-community:latest as
of 2026-04-19.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions