1
我努力學習REST做了一個簡單的API沒有安全測試,但我有此錯誤:軌,路線和REST
ActionController::RoutingError (No route matches [GET] "/api"):
當我查看路由我有這個。
Rails.application.routes.draw do
resources :users do
get 'search', on: :collection
end
# A singleton resource and so no paths requiring ids are generated
# Also, don't want to support editing of the session
resource :session, only: [:new, :create, :destroy]
namespace :api, defaults: {format: :json} do
resources :broadcast, only: [:create, :index] #Have I set this up wrong?
end
resources :broadcasts, except: [:edit, :update]
get 'home', to: 'home#index', as: :home
root 'home#index'
http://guides.rubyonrails.org/routing.html 結束 我曾在Ruby小腳本,試圖訪問,但我只是得到一個503的時候,我使用c9.io發展會是這樣的問題?這裏是我試圖列出一些廣播的ruby代碼。
require "net/http"
require "uri"
uri = URI.parse("http://assignment-cloned-pas43.c9users.io")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new("/api/broadcasts/")
response = http.request(request)
puts response.code
puts response.body
這裏是我的目錄的 https://snag.gy/EVm3HN.jpg