I’m having trouble wiring up the view for my new guess controller into the cards view of the deck.
I have:
<div>
<%= link_to card.front, [@deck, card] %>
<%= link_to "Guess", show_guess_path(@deck, card) %>
<%= link_to "Edit", edit_deck_card_path(@deck, card) %>
<%= link_to "Delete", [@deck, card], method: :delete, confirm: "Are you sure?" %>
</div>
and am getting:
NoMethodError in Decks#show
Showing /Users/cpatti/src/intro-rails-ruby/flashcards/app/views/decks/show.html.erb where line #7 raised:
undefined method `show_guess_path' for #<#<Class:0x007fc7b76da228>:0x007fc7b75bc1e8>
Extracted source (around line #7):
4: <% @cards.each do |card| %>
5: <div>
6: <%= link_to card.front, [@deck, card] %>
7: <%= link_to "Guess", show_guess_path(@deck, card) %>
8: <%= link_to "Edit", edit_deck_card_path(@deck, card) %>
9: <%= link_to "Delete", [@deck, card], method: :delete, confirm: "Are you sure?" %>
10: </div>
I also tried deck_guess_path.
My routes look like this:
Flashcards::Application.routes.draw do
root to: "homes#index"
resource :session, only: [:new, :create, :destroy]
resources :users, only: [:new, :create]
resources :decks do
resources :cards, except: :index
resource :guess, only: :show
end
end
I don’t understand why things like edit_deck_card_path works and deck_guess_path doesn’t.
I suspect I’m missing some fundamental connection between routing, controllers, and automatic path generation.
My entire repository is at https://github.com/feoh/intro-rails-ruby
Thanks for any clues you may have.
-Chris