2
votes

I am missing the contacts#show prefix 'contact' as seen below.

rake routes

               contacts GET    /contacts(.:format)                     contacts#index
                        POST   /contacts(.:format)                     contacts#create
            new_contact GET    /contacts/new(.:format)                 contacts#new
           edit_contact GET    /contacts/:id/edit(.:format)            contacts#edit
                        GET    /contacts/:id(.:format)                 contacts#show
                        PATCH  /contacts/:id(.:format)                 contacts#update
                        PUT    /contacts/:id(.:format)                 contacts#update
                        DELETE /contacts/:id(.:format)                 contacts#destroy

I am thinking this is the reason why I am getting a dot instead of a slash when clicking the following link.

_contact.html.erb

<%= link_to "delete contact", contact, method: :delete,
                                    data: { confirm: "You sure?" } %>

The server logs the proper DELETE request, however, cannot render /contact.26 instead of the correct /contacts/26.

Started DELETE "/contact.26" for 128.177.12.30 at 2016-04-13 21:04:30 +0000

ActionController::RoutingError (No route matches [DELETE] "/contact.26"):

Every post I've come across with a dot instead of a slash seems to stem from a pluralization error, however, I don't believe this is the case here.

In addition, I've removed resources :contacts from my routes file, run $ rake routes, added resources :contacts, run $ rake routes, and the problem persists.

This problem seems to be unique to the contacts model, as the rest of my models aren't missing any prefixes or having this error when deleting.

How do I add the 'contact' prefix back to 'contacts#show'?

routes.rb file for reference:

Rails.application.routes.draw do
  root 'static_pages#home'
  get 'help' => 'static_pages#help'
  get 'about' => 'static_pages#about'
  get 'contact' => 'static_pages#contact'
  get 'signup' => 'users#new'
  get 'login' => 'sessions#new'
  get 'newevent' => 'events#new'
  get 'newteam' => 'teams#new'
  get 'newperformance' => 'performances#new'
  get 'newhotel' => 'hotels#new'
  get 'newcontact' => 'contacts#new'
  get 'newflight' => 'flights#new'
  get 'newground' => 'grounds#new'
  get 'newguest' => 'guests#new'
  post 'login' => 'sessions#create'
  delete 'logout' => 'sessions#destroy'
  resources :users
  resources :events
  resources :teams do
    member do
      get :events
    end
  end
  resources :performances
  resources :hotels
  resources :contacts
  resources :flights
  resources :grounds
  resources :guests
  resources :account_activations, only: [:edit]
  resources :password_resets, only: [:new, :create, :edit, :update]
end
3
Try <%= link_to "delete contact", contact_path(contact), method: :delete, data: { confirm: "You sure?" } %>Abhi
Same routing error, unfortunately.ncarroll

3 Answers

0
votes

you may have a conflict between the routes set by

 resources :contacts

and

get 'contact' => 'static_pages#contact'

The easiest solution is probably to change the static page's links. Best to keep the resources together if you can.

0
votes

I just came across this same error.

the fix to my issue was that 's' at the end of resources

I had 'resource', and getting the same problem as you.

I changed it to 'resources' and it fixed my problem

in my case was just a typo.

0
votes

This error showed up for me yesterday. What fixed it was deleting helper files that were not being used. Might be worth a try for you.