mercredi 8 juin 2022

Ruby - Has_many through returns syntax error

When I try the following code

  has_many: users, through: :miq_groups, :foreign_key => :current_group_id, :primary_key => :miq_group_id;

I get RipperRubyParser::SyntaxError: syntax error, unexpected ':', expecting 'end' error.

  has_many :miq_groups, :foreign_key => :id, :primary_key => :miq_group_id;
  has_many :entitlements, through: :miq_groups; 
  has_many :miq_user_roles, through: :entitlements;

  has_many: users, through: :miq_groups, :foreign_key => :current_group_id, :primary_key => :miq_group_id;

Users table has current_group_id and miq_groups table has miq_group_id and both are foreign_key not primary.

Any idea how to resolve the error? I was just to include has_many: users.

Aucun commentaire:

Enregistrer un commentaire