diff --git a/app/controllers/ai_tags_controller.rb b/app/controllers/ai_tags_controller.rb index b02616ba0..93dab3d92 100644 --- a/app/controllers/ai_tags_controller.rb +++ b/app/controllers/ai_tags_controller.rb @@ -10,7 +10,7 @@ class AITagsController < ApplicationController params[:search][:is_posted] ||= "true" if request.format.html? @ai_tags = authorize AITag.visible(CurrentUser.user).paginated_search(params, limit: limit, count_pages: false) - @ai_tags = @ai_tags.includes(:media_asset, :tag, :post) if request.format.html? + @ai_tags = @ai_tags.includes(:tag, media_asset: :post) if request.format.html? respond_with(@ai_tags) end diff --git a/app/models/ai_tag.rb b/app/models/ai_tag.rb index 103ca93fc..f88562648 100644 --- a/app/models/ai_tag.rb +++ b/app/models/ai_tag.rb @@ -47,12 +47,12 @@ class AITag < ApplicationRecord # True if the AI tag is present on the post; false if the AI tag is not on the post, or the asset isn't a post yet. def post_tagged? - if post.nil? + if media_asset.post.nil? false elsif tag.name =~ /\Arating:(.)\z/ - post.rating == $1 + media_asset.post.rating == $1 else - post.has_tag?(tag.name) + media_asset.post.has_tag?(tag.name) end end diff --git a/app/views/ai_tags/_preview.html.erb b/app/views/ai_tags/_preview.html.erb index e843fc092..3432c25a6 100644 --- a/app/views/ai_tags/_preview.html.erb +++ b/app/views/ai_tags/_preview.html.erb @@ -3,10 +3,11 @@
<%= link_to "#{ai_tag.tag.pretty_name}", ai_tags_path(search: search_params.merge(tag_name: ai_tag.tag.name)), class: "tag-type-#{ai_tag.tag.category}", "data-tag-name": ai_tag.tag.name, title: ai_tag.tag.pretty_name %> - <%= link_to "#{ai_tag.score}%", ai_tags_path(search: search_params.merge(tag_name: ai_tag.tag.name, score: ">=#{ai_tag.score}")), class: "block tag-type-#{ai_tag.tag.category}", "data-tag-name": ai_tag.tag.name %> +
+ <%= link_to "#{ai_tag.score}%", ai_tags_path(search: search_params.merge(tag_name: ai_tag.tag.name, score: ">=#{ai_tag.score}")), class: "tag-type-#{ai_tag.tag.category}", "data-tag-name": ai_tag.tag.name %>
- <% if ai_tag.post.nil? || !policy(ai_tag).update? %> + <% if media_asset.post.nil? || !policy(ai_tag).update? %> <%= button_to "Add", nil, class: "button-primary button-sm", disabled: true %> <% elsif ai_tag.post_tagged? %> <%= button_to "Remove", tag_ai_tag_path(media_asset_id: ai_tag.media_asset, tag_id: ai_tag.tag), remote: true, method: :put, params: { mode: "remove" }, class: "button-outline-danger button-sm", title: "Remove the tag from the post" %>