我在做一個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"}
爲什麼,當我打印出來!與看跌期權solved_before ,它是否認爲錯誤而不是真實?
'false'和''false「'有很大的區別。哪一個是你的? –