Hi matenauta
Yes, it would be possible by using the logic here:
Example (tested and working):
tag = Tag.find_by_name("design")
topics_id = Topic.joins(:topic_tags).where("topic_tags.tag_id = ?", tag.id).pluck(:id)
Post.where(topic_id: topics_id, post_number: 1).update_all(wiki: true)