please I just developed a game in Ruby on Rails, and I am about to deploy it. Everything works fine in the development stage but keeps on getting "ActionView::Template::Error (no implicit conversion of Array into String):" in the deployment environment. The error pointed me to a particular line of code which is,
def passcode
JSON.parse(game.passcode)
end
This is the output of my object before the JSON.parse;
"[\"ORANGE\", \"YELLOW\", \"PURPLE\", \"GREEN\"]"
The method above output;
["ORANGE", "YELLOW", "PURPLE", "GREEN"]
The passcode was used to get the game outcome after the player won or lost the game.
def game_outcome
if !attempts.empty? && passcode == last_attempt
return "Congratulations!"
elsif attempts.size == guesses.size && passcode != last_attempt
return "Sorry, you've lost! It was a bit difficult"
end
end
I have tried to see the output of the method on my local machine and it outputs an array, which I think it's the right thing
I will appreciate your assistance.
Aucun commentaire:
Enregistrer un commentaire