Check if record exists from controller in Rails
问题 In my app a User can create a Business. When they trigger the index action in my BusinessesController I want to check if a Business is related to the current_user.id : If yes: display the business. If no: redirect to the new action. I was trying to use this: if Business.where(:user_id => current_user.id) == nil # no business found end But it always returns true even when the business doesn\'t exist... How can I test if a record exists in my database? 回答1: Why your code does not work? The