I have a nested resource which appears like so in my routes:
resource :reviews do
resource :entries
end
I’m trying to create a link for a new entry path like so:
<%= link_to "New Entry", new_review_entry_path(@review) %>
Unfortunately, I keep getting this error message:
undefined method `new_review_entry_path' for #<#<Class:0x5150d78>:0x483c798>
I checked rake routes, and it turns out that the route should be pluralized into:
new_reviews_entries_path(@review)
Unfortunately, when I do that, then I get an odd url:
/reviews/entries/new.1
Obviously, that doesn’t work, either. Any idea what’s going on here?
It’s
resources, notresource. Your first try was the right one 😉You should use
resourcewhen the resource is “unique”. For instance, if a user has one profile, you would do: