I am new to Ruby on Rails and I have basic knowledge of mysql. I am using MySQL db. My question is -- how to check if a row is exists or not in a table. I have tried this code but it's not going straight to the else
block, not the if
block:
@tasks = User.find_by("user_name = ? AND password = ?", params[:user_name], params[:password])
if @tasks
redirect_to action: 'index', status: 302
else
redirect_to action: 'detail', status: 302
end