/posts/random: fix reorder(nil).first deprecation warning

DEPRECATION WARNING: `.reorder(nil)` with `.first` / `.first!` no
    longer takes non-deterministic result in Rails 6.2. To continue
    taking non-deterministic result, use `.take` / `.take!` instead.
    (called from random at /home/user/src/danbooru/app/controllers/posts_controller.rb:91)
This commit is contained in:
evazion
2021-09-02 03:47:50 -05:00
parent 1bb383703d
commit c29539d44e

View File

@@ -88,7 +88,7 @@ class PostsController < ApplicationController
end
def random
@post = Post.user_tag_match(params[:tags]).random(1).first
@post = Post.user_tag_match(params[:tags]).random(1).take
raise ActiveRecord::RecordNotFound if @post.nil?
authorize @post
respond_with(@post) do |format|