我在控制器中有一个动作,如下所示:
def show
@project = current_customer.projects.where(id: params[:project_id]).first
if @project
@feature = @project.features.where(id: params[:feature_id]).first
if @feature
@conversation = @feature.conversations.where(id: params[:id]).first
unless @conversation
head 401
end
else
head 401
end
else
head 401
end
end
问题是重复head 401
。有没有更好的方法来编写这个动作?