Ensure that we have a slug and owner before attempting to lookup an article (#5079)

This commit is contained in:
Molly Struve 2019-12-11 12:19:46 -06:00 committed by Ben Halpern
parent 145db47a3a
commit 6ba2853168

View file

@ -217,7 +217,7 @@ class ArticlesController < ApplicationController
def set_article
owner = User.find_by(username: params[:username]) || Organization.find_by(slug: params[:username])
found_article = if params[:slug]
found_article = if params[:slug] && owner
owner.articles.find_by(slug: params[:slug])
else
Article.includes(:user).find(params[:id])