Skip to content

Commit

Permalink
Handle STI polymorphic associations
Browse files Browse the repository at this point in the history
  • Loading branch information
graudeejs committed Jul 31, 2015
1 parent 65281b6 commit de41be6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion releaf-core/app/lib/releaf/search.rb
Expand Up @@ -85,7 +85,7 @@ def join_reflection_without_through(reflection, table)
end

if reflection.type
polymorphic_type_condition = table2[reflection.type.to_sym].eq(klass.name)
polymorphic_type_condition = table2[reflection.type.to_sym].eq(klass.base_class.name)
join_condition = join_condition.and(polymorphic_type_condition)
end

Expand Down
2 changes: 2 additions & 0 deletions releaf-core/spec/features/search_spec.rb
Expand Up @@ -108,6 +108,8 @@
@comment6 = Comment.create!(text: "small", comment_author: @comment_author2, blog_post: @post4)
end

it "searchs polymorphic targets by base class"

it "support has_one polymorphic target" do
params = {
relation: Comment,
Expand Down

0 comments on commit de41be6

Please sign in to comment.