postgres_tree 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +34 -0
- data/lib/postgres_tree/concerns/model/active_record.rb +81 -0
- data/lib/postgres_tree/engine.rb +4 -0
- data/lib/postgres_tree/version.rb +3 -0
- data/lib/postgres_tree.rb +2 -0
- data/lib/tasks/postgres_tree_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/person.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +87 -0
- data/test/dummy/config/database.yml.travis +4 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +78 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +56 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20140918023556_create_people.rb +10 -0
- data/test/dummy/db/schema.rb +26 -0
- data/test/dummy/log/development.log +64 -0
- data/test/dummy/log/test.log +3233 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/fixtures/people.yml +15 -0
- data/test/dummy/test/models/person_test.rb +86 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/postgres_tree_test.rb +7 -0
- data/test/test_helper.rb +41 -0
- metadata +182 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
+
|
22
|
+
en:
|
23
|
+
hello: "Hello world"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
3
|
+
# See how all your routes lay out with "rake routes".
|
4
|
+
|
5
|
+
# You can have the root of your site routed with "root"
|
6
|
+
# root 'welcome#index'
|
7
|
+
|
8
|
+
# Example of regular route:
|
9
|
+
# get 'products/:id' => 'catalog#view'
|
10
|
+
|
11
|
+
# Example of named route that can be invoked with purchase_url(id: product.id)
|
12
|
+
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
13
|
+
|
14
|
+
# Example resource route (maps HTTP verbs to controller actions automatically):
|
15
|
+
# resources :products
|
16
|
+
|
17
|
+
# Example resource route with options:
|
18
|
+
# resources :products do
|
19
|
+
# member do
|
20
|
+
# get 'short'
|
21
|
+
# post 'toggle'
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# collection do
|
25
|
+
# get 'sold'
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
|
29
|
+
# Example resource route with sub-resources:
|
30
|
+
# resources :products do
|
31
|
+
# resources :comments, :sales
|
32
|
+
# resource :seller
|
33
|
+
# end
|
34
|
+
|
35
|
+
# Example resource route with more complex sub-resources:
|
36
|
+
# resources :products do
|
37
|
+
# resources :comments
|
38
|
+
# resources :sales do
|
39
|
+
# get 'recent', on: :collection
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
|
43
|
+
# Example resource route with concerns:
|
44
|
+
# concern :toggleable do
|
45
|
+
# post 'toggle'
|
46
|
+
# end
|
47
|
+
# resources :posts, concerns: :toggleable
|
48
|
+
# resources :photos, concerns: :toggleable
|
49
|
+
|
50
|
+
# Example resource route within a namespace:
|
51
|
+
# namespace :admin do
|
52
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
53
|
+
# # (app/controllers/admin/products_controller.rb)
|
54
|
+
# resources :products
|
55
|
+
# end
|
56
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: 48c5ac6e637a08aed5f2b16e9f70d31782bbc25e0061a4c06e39ae222c680ac006fde8ac71c80c3ccc29f199aad3e06c93547d21447f925fcf3c3862811b8317
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: 0577287fbb66d658f078f0ded17a0fd09711912101616b5549ec1bc5377db7ef2d4967fdb624945186741c5170b5f484faf58b91f4c05674f78cf9dc38bac0a4
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(version: 20140918023556) do
|
15
|
+
|
16
|
+
# These are extensions that must be enabled in order to support this database
|
17
|
+
enable_extension "plpgsql"
|
18
|
+
|
19
|
+
create_table "people", force: true do |t|
|
20
|
+
t.string "name"
|
21
|
+
t.integer "parent_id"
|
22
|
+
t.datetime "created_at"
|
23
|
+
t.datetime "updated_at"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
[1m[36m (28.5ms)[0m [1mCREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) [0m
|
2
|
+
[1m[35m (62.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
3
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.4ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
4
|
+
Migrating to CreatePeople (20140918023556)
|
5
|
+
[1m[35m (0.2ms)[0m BEGIN
|
6
|
+
[1m[36m (55.9ms)[0m [1mCREATE TABLE "people" ("id" serial primary key, "name" character varying(255), "parent_id" integer, "created_at" timestamp, "updated_at" timestamp) [0m
|
7
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140918023556"]]
|
8
|
+
[1m[36m (12.6ms)[0m [1mCOMMIT[0m
|
9
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.3ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
10
|
+
[1m[36mPerson Load (0.9ms)[0m [1mSELECT "people".* FROM "people" ORDER BY "people"."id" ASC LIMIT 1[0m
|
11
|
+
[1m[35mPerson Load (0.7ms)[0m SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
12
|
+
SELECT id, parent_id, ARRAY[id]
|
13
|
+
FROM people
|
14
|
+
WHERE id =
|
15
|
+
UNION ALL
|
16
|
+
SELECT people.id, people.parent_id, path || people.id
|
17
|
+
FROM search_tree
|
18
|
+
JOIN people ON people.id = search_tree.parent_id
|
19
|
+
WHERE NOT people.id = ANY(path)
|
20
|
+
)
|
21
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
22
|
+
))
|
23
|
+
PG::SyntaxError: ERROR: syntax error at or near "UNION"
|
24
|
+
LINE 5: UNION ALL
|
25
|
+
^
|
26
|
+
: SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
27
|
+
SELECT id, parent_id, ARRAY[id]
|
28
|
+
FROM people
|
29
|
+
WHERE id =
|
30
|
+
UNION ALL
|
31
|
+
SELECT people.id, people.parent_id, path || people.id
|
32
|
+
FROM search_tree
|
33
|
+
JOIN people ON people.id = search_tree.parent_id
|
34
|
+
WHERE NOT people.id = ANY(path)
|
35
|
+
)
|
36
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
37
|
+
))
|
38
|
+
[1m[36mPerson Load (1.2ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
39
|
+
SELECT id, parent_id, ARRAY[id]
|
40
|
+
FROM people
|
41
|
+
WHERE id =
|
42
|
+
UNION ALL
|
43
|
+
SELECT people.id, people.parent_id, path || people.id
|
44
|
+
FROM search_tree
|
45
|
+
JOIN people ON people.id = search_tree.parent_id
|
46
|
+
WHERE NOT people.id = ANY(path)
|
47
|
+
)
|
48
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
49
|
+
))[0m
|
50
|
+
PG::SyntaxError: ERROR: syntax error at or near "UNION"
|
51
|
+
LINE 5: UNION ALL
|
52
|
+
^
|
53
|
+
: SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
54
|
+
SELECT id, parent_id, ARRAY[id]
|
55
|
+
FROM people
|
56
|
+
WHERE id =
|
57
|
+
UNION ALL
|
58
|
+
SELECT people.id, people.parent_id, path || people.id
|
59
|
+
FROM search_tree
|
60
|
+
JOIN people ON people.id = search_tree.parent_id
|
61
|
+
WHERE NOT people.id = ANY(path)
|
62
|
+
)
|
63
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
64
|
+
))
|