Follow AR like naming of factory method

上级 66d94ed7
......@@ -4,7 +4,7 @@
class ActiveStorage::Controllers::VariantsController < ActionController::Base
def show
if blob_key = decode_verified_key
variant = ActiveStorage::Variant.lookup(blob_key: blob_key, variation_key: params[:variation_key])
variant = ActiveStorage::Variant.find_or_create_by(blob_key: blob_key, variation_key: params[:variation_key])
redirect_to variant.url
else
head :not_found
......
......@@ -7,7 +7,7 @@ class ActiveStorage::Variant
attr_reader :blob, :variation
delegate :service, to: :blob
def self.lookup(blob_key:, variation_key:)
def self.find_or_create_by(blob_key:, variation_key:)
new ActiveStorage::Blob.find_by!(key: blob_key), variation: verifier.verify(variation_key)
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册