我正在对此方法进行ajax调用
def check_solution
puzzle = Puzzle.find(params[:id])
solved = puzzle.grid.solution == params[:solution].to_s
solved_before = params[:solved_before]
puts !solved_before
if(solved && !solved_before)
Puzzle.find(params[:id]).increment!(:times_solved, by =1)
end
respond_to do |format|
response = { :status => "ok", :message => "Success!", :html => solved}
format.json { render json: response }
end
end
从我的本地服务器进入的参数是
Parameters: {"solution"=>"0001000010110011001100000", "solved_before"=>"false", "id"=>"3758"}
为什么,当我打印出来时!solve_before with puts,它会说假而不是真吗?
答案 0 :(得分:2)
那是因为solved_before
以字符串形式出现而不是布尔值。