在我的控制器中,如果用户退出,我将重定向用户。然后我正在拉一份专业人士名单..如果不存在,也需要重定向到那里。有没有办法解决这个困境?
def purchase
@style = Style.find(params[:id])
if user_signed_in? && current_user.consumer
@professionals = Professional.where(...)
if @professionals.empty?
redirect_to style_path(@style)
else
...
end
...
else
flash[:error] = "Please sign in as a consumer to access this page"
redirect_to style_path(@style)
end
end