Reputation: 443
I am having a problem with my routes. Just noticed a strange thing. I have no :id in my show/edit/... routes.
This is my rake.routes output:
WARNING: Nokogiri was built against LibXML version 2.9.0, but has dynamically loaded 2.9.2
Prefix Verb URI Pattern Controller#Action
new_person_session GET /persons/sign_in(.:format) devise/sessions#new
person_session POST /persons/sign_in(.:format) devise/sessions#create
destroy_person_session DELETE /persons/sign_out(.:format) devise/sessions#destroy
person_password POST /persons/password(.:format) devise/passwords#create
new_person_password GET /persons/password/new(.:format) devise/passwords#new
edit_person_password GET /persons/password/edit(.:format) devise/passwords#edit
PATCH /persons/password(.:format) devise/passwords#update
PUT /persons/password(.:format) devise/passwords#update
supplier_password POST /suppliers/password(.:format) devise/passwords#create
new_supplier_password GET /suppliers/password/new(.:format) devise/passwords#new
edit_supplier_password GET /suppliers/password/edit(.:format) devise/passwords#edit
PATCH /suppliers/password(.:format) devise/passwords#update
PUT /suppliers/password(.:format) devise/passwords#update
facilitator_password POST /facilitators/password(.:format) devise/passwords#create
new_facilitator_password GET /facilitators/password/new(.:format) devise/passwords#new
edit_facilitator_password GET /facilitators/password/edit(.:format) devise/passwords#edit
PATCH /facilitators/password(.:format) devise/passwords#update
PUT /facilitators/password(.:format) devise/passwords#update
customer_password POST /customers/password(.:format) devise/passwords#create
new_customer_password GET /customers/password/new(.:format) devise/passwords#new
edit_customer_password GET /customers/password/edit(.:format) devise/passwords#edit
PATCH /customers/password(.:format) devise/passwords#update
PUT /customers/password(.:format) devise/passwords#update
cancel_customer_registration GET /customers/cancel(.:format) devise/registrations#cancel
customer_registration POST /customers(.:format) devise/registrations#create
new_customer_registration GET /customers/sign_up(.:format) devise/registrations#new
edit_customer_registration GET /customers/edit(.:format) devise/registrations#edit
PATCH /customers(.:format) devise/registrations#update
PUT /customers(.:format) devise/registrations#update
DELETE /customers(.:format) devise/registrations#destroy
home_index GET /home/index(.:format) home#index
root GET / home#index
suppliers_index GET /suppliers/index(.:format) suppliers#index
facilitators_index GET /facilitators/index(.:format) facilitators#index
customers_index GET /customers/index(.:format) customers#index
new_customers GET /customers/new(.:format) customers#new
customers_newCustomer POST /customers/newCustomer(.:format) customers#newCustomer
customers_editCustomer GET /customers/editCustomer(.:format) customers#editCustomer
parties POST /parties(.:format) parties#create
new_parties GET /parties/new(.:format) parties#new
edit_parties GET /parties/edit(.:format) parties#edit
GET /parties(.:format) parties#show
PATCH /parties(.:format) parties#update
PUT /parties(.:format) parties#update
DELETE /parties(.:format) parties#destroy
parties_index GET /parties/index(.:format) parties#index
visitors_new POST /visitors/new(.:format) visitors#new
visitors_create POST /visitors/create(.:format) visitors#create
this is my routes.rb
:
Rails.application.routes.draw do
# devise_for :people
devise_for :persons, :skip => :registrations
devise_for :suppliers, :facilitators, skip: [:registrations, :sessions]
devise_for :customers, :skip => :sessions
# routes for all users
authenticated :persons do
end
# routes only for customers
authenticated :customers, lambda {|u| u.type == "Customer"} do
end
# routes only for companies
authenticated :facilitators, lambda {|u| u.type == "Facilitator"} do
end
# routes only for suppliers
authenticated :suppliers, lambda {|u| u.type == "Supplier"} do
end
# mde toevoegeingen
get 'home/index'
root to: "home#index"
get 'suppliers/index'
get 'facilitators/index'
get 'customers/index'
resource :customers, :only => :new
match 'customers/newCustomer', to: 'customers#newCustomer', via: :post
match 'customers/editCustomer', to: 'customers#editCustomer', via: :get
resource :parties
get 'parties/index'
match 'visitors/new', to: 'visitors#new', via: :post
match 'visitors/create', to: 'visitors#create', via: :post
end
My urls show a '.' instead of a '/' before the 'id'. this is an example url for the show
method of a model:
http://localhost:3000/parties.2
The strange thing is that the normal routing is working. Strange because the dot is intended for defining the format.
Now I need the format becase of a remote: true
behaviour I am implementing I am getting into troubles.
What did I do wrong?
regards Martijn
Upvotes: 0
Views: 51
Reputation: 457
Just like Brad Werth said in comments.
the plural resources
resources :photos
creates
GET /photos Photos index display a list of all photos
GET /photos/new Photos new return an HTML form for creating a new photo
POST /photos Photos create create a new photo
GET /photos/1 Photos show display a specific photo
GET /photos/1/edit Photos edit return an HTML form for editing a photo
PUT /photos/1 Photos update update a specific photo
DELETE /photos/1 Photos destroy delete a specific photo
in contrast to Singular Resources
You can also apply RESTful routing to singleton resources within your application. In this case, you use map.resource instead of map.resources and the route generation is slightly different. For example, a routing entry of
resource :geocoded
GET /geocoder/new Geocoders new return an HTML form for creating the new geocoder
POST /geocoder Geocoders create create the new geocoder
GET /geocoder Geocoders show display the one and only geocoder resource
GET /geocoder/edit Geocoders edit return an HTML form for editing the geocoder
PUT /geocoder Geocoders update update the one and only geocoder resource
DELETE /geocoder Geocoders destroy delete the geocode resource
Upvotes: 2