我正在尝试创建一个同时具有活动和neo4j模型的应用程序,我想为我的neo4j模型使用以下应用程序:
module Neo
class Usernode
include Neo4j::ActiveNode
property :first_name, type: String
property :last_name, type: String
property :address, type: String
end
end
并在我的控制器中使用它们,如下所示:
class UsernodesController < ApplicationController
def index
@usernodes = Neo::Usernode.all
end
在我的路由中.db文件中,我有以下路由:
Rails.application.routes.draw do
resources :usernodes, path: '/usernodes'
end
这样做的问题是它只产生具有'/neo/usernodes/'
的路由,而我只想使用具有'/usernodes/'
的路由。
是否可以只生产'/usernodes/'
?如果是,我该怎么做?
那么如果我在路由中使用.db:
resources :usernodes, path: '/usernodes'
我收到以下错误:
Processing by UsernodesController#new as HTML
Rendered usernodes/_form.html.erb (12.2ms)
Rendered usernodes/new.html.erb within layouts/application (12.7ms)
Completed 500 Internal Server Error in 15ms
ActionView::Template::Error (undefined method 'neo_usernodes_path' for
#<#<Class:0x0000000788e968>:0x000000089f3c08>):
1: <%= form_for(@usernode) do |f| %>
2: <% if @usernode.errors.any? %>
3: <div id="error_explanation">
4: <h2><%= pluralize(@usernode.errors.count, "error") %> prohibited this usernode from being saved:</h2>
这是我的路线:
Prefix Verb URI Pattern Controller#Action
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PATCH /users/:id(.:format) users#update
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
usernodes GET /usernodes(.:format) usernodes#index
POST /usernodes(.:format) usernodes#create
new_usernode GET /usernodes/new(.:format) usernodes#new
edit_usernode GET /usernodes/:id/edit(.:format) usernodes#edit
usernode GET /usernodes/:id(.:format) usernodes#show
PATCH /usernodes/:id(.:format) usernodes#update
PUT /usernodes/:id(.:format) usernodes#update
DELETE /usernodes/:id(.:format) usernodes#destroy
请尝试以下操作:
resources :usernodes, module: 'neo', path: 'usernodes'