所以,我有一个命名路线:
match 'ip/get/:ip' => 'ip_addresses#show', :via => :get
如您所见,我希望 ip(在“get”之后)是动态的,但是当我尝试它时,我不断收到路由错误。这是我的路线:
root / ip_addresses#index
ip_add POST /ip/add(.:format) ip_addresses#create
GET /ip/add(.:format) ip_addresses#new
ip_all GET /ip/all(.:format) ip_addresses#index
GET /ip/get/:ip(.:format) ip_addresses#show
DELETE /ip/all(.:format) ip_addresses#destroy
这是我的show
行动:
def show
IpAddress.find(params[:id])
end
编辑:路由错误:
ActionController::RoutingError (No route matches [GET] "/ip/get/1.2.3.4"):
我已经阅读了 Rails Routing from the Outside In Guide ( http://guides.rubyonrails.org/routing.html ) 但我自然可能忽略了一些东西。任何帮助表示赞赏。谢谢!