0
鐵軌邊的文件說:路線/相冊/新地圖到相冊#顯示
GET |/albums/new |相冊#new |返回一個HTML表單創建 新專輯
但是,當我嘗試這樣做,我得到:
Started GET "/api/albums/new" for 172.18.0.1 at 2017-08-10 20:12:06 +0000
Processing by API::AlbumsController#show as */*
這是我關於專輯的路由器:
Rails.application.routes.draw do
namespace :api, constraints: {format: :json} do
resources :albums
put '/albums/:id/photo/:photo' => "albums#add_photo"
put '/albums/:id/bucket' => "albums#add_bucket"
get '/albums/:id/photos' => 'albums#photos'
end
end
問題: 爲什麼/ API /專輯/新地圖到API :: AlbumsController#顯示而不是API :: AlbumsController#新
增加:
我rake routes
輸出:
Prefix Verb URI Pattern Controller#Action
api_users_login POST /api/users/login(.:format) api/users#authenticate {:format=>:json}
api_users_from_token GET /api/users/from_token(.:format) api/users#validate_token {:format=>:json}
api_users GET /api/users(.:format) api/users#index {:format=>:json}
POST /api/users(.:format) api/users#create {:format=>:json}
api_user GET /api/users/:id(.:format) api/users#show {:format=>:json}
PATCH /api/users/:id(.:format) api/users#update {:format=>:json}
PUT /api/users/:id(.:format) api/users#update {:format=>:json}
DELETE /api/users/:id(.:format) api/users#destroy {:format=>:json}
api_albums GET /api/albums(.:format) api/albums#index {:format=>:json}
POST /api/albums(.:format) api/albums#create {:format=>:json}
api_album GET /api/albums/:id(.:format) api/albums#show {:format=>:json}
PATCH /api/albums/:id(.:format) api/albums#update {:format=>:json}
PUT /api/albums/:id(.:format) api/albums#update {:format=>:json}
DELETE /api/albums/:id(.:format) api/albums#destroy {:format=>:json}
api PUT /api/albums/:id/photo/:photo(.:format) api/albums#add_photo {:format=>:json}
PUT /api/albums/:id/bucket(.:format) api/albums#add_bucket {:format=>:json}
GET /api/albums/:id/photos(.:format) api/albums#photos {:format=>:json}
api_pages GET /api/pages(.:format) api/pages#index {:format=>:json}
api_photos_taglist GET /api/photos/taglist(.:format) api/photos#taglist {:format=>:json}
api_photos_bucket GET /api/photos/bucket(.:format) api/photos#bucket {:format=>:json}
POST /api/photos/bucket/rotate/:degrees(.:format) api/photos#rotate_bucket {:format=>:json}
api_photos GET /api/photos(.:format) api/photos#index {:format=>:json}
POST /api/photos(.:format) api/photos#create {:format=>:json}
api_photo GET /api/photos/:id(.:format) api/photos#show {:format=>:json}
PATCH /api/photos/:id(.:format) api/photos#update {:format=>:json}
PUT /api/photos/:id(.:format) api/photos#update {:format=>:json}
DELETE /api/photos/:id(.:format) api/photos#destroy {:format=>:json}
GET /api/photos/:id/rotate(/:degrees)(.:format) api/photos#rotate {:format=>:json}
POST /api/photos/:id/comment/add(.:format) api/photos#comment {:format=>:json}
DELETE /api/photos/:id/comment/delete(.:format) api/photos#uncomment {:format=>:json}
POST /api/photos/:id/tag/add(.:format) api/photos#tag {:format=>:json}
DELETE /api/photos/:id/tag/delete(.:format) api/photos#untag {:format=>:json}
POST /api/photos/:id/like/toggle(.:format) api/photos#like_toggle {:format=>:json}
POST /api/photos/:id/bucket/toggle(.:format) api/photos#bucket_toggle {:format=>:json}
api_facets GET /api/facets(.:format) api/facets#index {:format=>:json}
POST /api/facets(.:format) api/facets#create {:format=>:json}
api_facet GET /api/facets/:id(.:format) api/facets#show {:format=>:json}
PATCH /api/facets/:id(.:format) api/facets#update {:format=>:json}
PUT /api/facets/:id(.:format) api/facets#update {:format=>:json}
DELETE /api/facets/:id(.:format) api/facets#destroy {:format=>:json}
api_catalogs_oauth_callback GET /api/catalogs/oauth_callback(.:format) api/catalogs#oauth_callback {:format=>:json}
GET /api/catalogs/:id/import(.:format) api/catalogs#import {:format=>:json}
GET /api/catalogs/:id/photos(.:format) api/catalogs#photos {:format=>:json}
api_catalogs GET /api/catalogs(.:format) api/catalogs#index {:format=>:json}
POST /api/catalogs(.:format) api/catalogs#create {:format=>:json}
api_catalog GET /api/catalogs/:id(.:format) api/catalogs#show {:format=>:json}
PATCH /api/catalogs/:id(.:format) api/catalogs#update {:format=>:json}
PUT /api/catalogs/:id(.:format) api/catalogs#update {:format=>:json}
DELETE /api/catalogs/:id(.:format) api/catalogs#destroy {:format=>:json}
api_locations_countries GET /api/locations/countries(.:format) api/locations#countries {:format=>:json}
api_locations_cities GET /api/locations/cities(.:format) api/locations#cities {:format=>:json}
api_locations GET /api/locations(.:format) api/locations#index {:format=>:json}
POST /api/locations(.:format) api/locations#create {:format=>:json}
api_location GET /api/locations/:id(.:format) api/locations#show {:format=>:json}
PATCH /api/locations/:id(.:format) api/locations#update {:format=>:json}
PUT /api/locations/:id(.:format) api/locations#update {:format=>:json}
DELETE /api/locations/:id(.:format) api/locations#destroy {:format=>:json}
api_photofiles GET /api/photofiles(.:format) api/photofiles#index {:format=>:json}
POST /api/photofiles(.:format) api/photofiles#create {:format=>:json}
api_photofile GET /api/photofiles/:id(.:format) api/photofiles#show {:format=>:json}
PATCH /api/photofiles/:id(.:format) api/photofiles#update {:format=>:json}
PUT /api/photofiles/:id(.:format) api/photofiles#update {:format=>:json}
DELETE /api/photofiles/:id(.:format) api/photofiles#destroy {:format=>:json}
GET /api/photofiles/:id/photoserve(.:format) api/photofiles#photoserve {:format=>:json}
PATCH /api/photofiles/:id/rotate(.:format) api/photofiles#rotate {:format=>:json}
GET /api/photofiles/:id/phash(.:format) api/photofiles#phash {:format=>:json}
api_jobs_list POST /api/jobs/list(.:format) api/jobs#list {:format=>:json}
api_jobs GET /api/jobs(.:format) api/jobs#index {:format=>:json}
POST /api/jobs(.:format) api/jobs#create {:format=>:json}
api_job GET /api/jobs/:id(.:format) api/jobs#show {:format=>:json}
PATCH /api/jobs/:id(.:format) api/jobs#update {:format=>:json}
PUT /api/jobs/:id(.:format) api/jobs#update {:format=>:json}
DELETE /api/jobs/:id(.:format) api/jobs#destroy {:format=>:json}
/resque #<Resque::Server app_file="/usr/local/bundle/gems/resque-1.27.4/lib/resque/server.rb">
root GET / photos#index
你的問題是什麼? – dbugger
路徑路徑'/ albums/new'與顯示'/ api/albums/new'的請求路徑不匹配。 –
@dbugger我希望我的編輯更清楚地向你 – martin