1

I am trying to build a simple app using Ruby on Rails. Essentially, I have a route that maps to a controller, whose view looks like this:

<div class="wishlist-container">
<% @wishlists.each do |w| %>
    <div class="wishlist-card">
        <h4><%= w.title %></h4>
        <%= link_to "View List", wishlist_path(w) %>
    </div>
<% end %>

Everything works correctly except for the link. For whatever reason, the link links to "." instead of "/" where <id> is the id. For example, it should link to /wishlist/1 but instead goes to /wishlist.1.

What is happening? How can I solve this problem?

AMACB
  • 1,290
  • 2
  • 18
  • 26

1 Answers1

1

For using paths helpers in your code , you should specify the resources , not only get or post in your routes.rb for example if you've

get 'wishlist/:id' It may not work .To make your path work you should specify get 'wishlist/:id', to: 'wishlist#show', as: 'wishlist'

For more information read Ruby docs and This article

Mani
  • 2,391
  • 5
  • 37
  • 81