Reputation: 983
The user is presented with a contact page where he can add a new contact by clicking the create button (Then the app takes him in a new page to add the contact's title)
<%= link_to "Create", new_contact_path %>
When I click create I get the following error:
undefined method `contacts_path' for #<#<Class:0xsomeHEX>:0xsomeHEX>
The above error disappears when I create the controller like this:
rails generate controller contacts
Also the routes.rb file points to:
resources :contact
Below are my files:
What I want to achieve is to go to the new contacts page by typing someurl/contact/new instead of /contacts/new
Upvotes: 0
Views: 41
Reputation: 396
In your config/routes.rb change your contacts route to this:
resources :contacts, path: "contact"
That gives you the ability to hit your routes using 'contact' instead of 'contacts'.
Upvotes: 2
Reputation: 1601
Please make these changes
contacts_controller.rb
class ContactsController < ApplicationController
....
end
routes.rb
resources :contacts
Your views folder should be views/contacts
Upvotes: 0