1

I'm making an ajax call to this method

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

The parameters going in from my local server are

Parameters: {"solution"=>"0001000010110011001100000", "solved_before"=>"false", "id"=>"3758"}

Why, when I print out !solved_before with puts, does it say false instead of true?

4

1 回答 1

2

那是因为solved_before以字符串而不是布尔值的形式出现。

于 2013-10-04T14:25:05.740 回答