Reputation: 1298
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?
Upvotes: 1
Views: 1081
Reputation: 2563
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
Upvotes: 1