我正在尝试使用active和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
在我的routes.db文件中我有以下路由:
Rails.application.routes.draw do
resources :usernodes, path: '/usernodes'
end
这个问题是它只生成'/neo/usernodes/'
的路由,我只想使用'/usernodes/'
的路由。
是否可以只生产'/usernodes/'
?如果是,我该怎么做?
然后如果我在routes.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
答案 0 :(得分:0)
请尝试以下:
resources :usernodes, module: 'neo', path: 'usernodes'