I work on a Rails project and I seem to have a route or controller problem which I do not understand. This is the error I receive: uninitialized constant Games Object.const_get(camel_cased_word) ^^^^^^^^^^ raise MissingController.new(error.message, error.name) ^^^^^. This are my routes: ` Rails.application.routes.draw do cccc devise_for :users
namespace :games do
resources :hangman, only: [:index]
end
get 'hangman/guess', to: 'hangman#guess'
root to: "pages#home"
end`
This is my controller: ` class HangmanController < ApplicationController def index @secret_word = "hangman" end
def guess
secret_word = "hangman"
incorrect_guesses = 0
render json: { secret_word: secret_word, incorrect_guesses: incorrect_guesses }
end
end`
This is my model:
class Hangman < ApplicationRecord belongs_to :user end
This is my index file:
<div id="hangman-game" data-controller="hangman"> <h1>Hangman Game</h1> <div> <p>Secret Word: <span data-target="hangman.secretWord"></span></p> <p>Incorrect Guesses: <span data-target="hangman.incorrectGuesses"></span></p> <p>Guesses Remaining: <span data-target="hangman.guessesRemaining"></span></p> </div> <div> <input type="text" data-target="hangman.guessInput" placeholder="Enter a letter"> <button data-action="click->hangman#guess">Guess</button> </div> </div>
I do not see why I have an error here. I used namespaces for once, I wanted to create different games in the app folder. So I used this path: app/games/hangman/models or views or controllers and their content. What do I do wrong? Thank you for your help and sorry in advance for all this code.
I expected my code to show but I cannot open the page at localhost/games/hangman...