【发布时间】:2018-03-09 14:49:10
【问题描述】:
我在 Rails 5 中使用 rails-jquery-autocomplete gem (https://github.com/bigtunacan/rails-jquery-autocomplete) 来让我的数据库搜索自动完成。不幸的是,我的列表模型已经存在的路线似乎干扰了我现在尝试建立的路线。
listings_controller.rb:
autocomplete :listing, :community, full:true, :extra_data => [:subdivision]
routes.rb:
get '/listings/:listing_id/:address/:mls', to: 'listings#show', as: 'listing'
post 'listings/:listing_id', to: 'clients#textme', as: 'new_text_client'
resources :listings do
get :autocomplete_listing_community, :on => :collection
end
通过resources: :listings do 传递所有三个路由得到:
ArgumentError: Invalid route name, already in use: 'listings'
You may have defined two routes with the same name using the `:as` option, or
you may be overriding a route already defined by a resource with the same
naming. For the latter, you can restrict the routes created with `resources`
as explained here: http://guides.rubyonrails.org/routing.html#restricting-the-
routes-created
当我运行rake routes 时。但是,如图所示执行此操作:
ArgumentError: Invalid route name, already in use: 'listings'
You may have defined two routes with the same name using the `:as` option, or
you may be overriding a route already defined by a resource with the same
naming. For the latter, you can restrict the routes created with `resources`
as explained here:
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
我如何让这些都一起工作?
【问题讨论】:
标签: jquery ruby-on-rails ruby autocomplete routes