Skip to content

Commit

Permalink
Fix #62
Browse files Browse the repository at this point in the history
  • Loading branch information
Yacine Petitprez committed Jan 10, 2019
1 parent 333db75 commit d6fd931
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/clear/model/modules/relations/has_many_through_macro.cr
Expand Up @@ -45,8 +45,10 @@ module Clear::Model::Relations::HasManyThroughMacro
%final_table = {{relation_type}}.table
%final_pkey = {{relation_type}}.pkey
%through_table = {{through}}.table
%through_key = {{foreign_key}} || {{relation_type}}.table.to_s.singularize + "_id"
%own_key = {{own_key}} || {{self_type}}.table.to_s.singularize + "_id"

%through_key = {% if foreign_key %} "{{foreign_key}}" {% else %} {{relation_type}}.table.to_s.singularize + "_id" {% end %}
%own_key = {% if own_key %} "{{own_key}}" {% else %} {{self_type}}.table.to_s.singularize + "_id" {% end %}

self_type = {{self_type}}

@cache.active "{{method_name}}"
Expand Down

0 comments on commit d6fd931

Please sign in to comment.