we_bridge_rails_engine_users 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/javascripts/users.js +2 -0
  6. data/app/assets/stylesheets/scaffold.css +56 -0
  7. data/app/assets/stylesheets/users.css +4 -0
  8. data/app/controllers/sessions_controller.rb +82 -0
  9. data/app/controllers/users_controller.rb +9 -0
  10. data/app/helpers/users_helper.rb +2 -0
  11. data/app/models/person.rb +13 -0
  12. data/app/models/person_name.rb +6 -0
  13. data/app/models/person_name_text.rb +24 -0
  14. data/app/models/person_status.rb +2 -0
  15. data/app/models/person_text.rb +4 -0
  16. data/app/models/user.rb +12 -0
  17. data/app/models/user_account.rb +13 -0
  18. data/app/models/user_text.rb +13 -0
  19. data/app/views/sessions/login.html.builder +23 -0
  20. data/app/views/users/_form.html.builder +14 -0
  21. data/app/views/users/edit.html.builder +1 -0
  22. data/app/views/users/index.html.builder +1 -0
  23. data/app/views/users/new.html.builder +1 -0
  24. data/app/views/users/show.html.builder +1 -0
  25. data/config/routes.rb +14 -0
  26. data/db/migrate/20150611132719_add_sessions_table.rb +12 -0
  27. data/db/migrate/20150612005752_create_people.rb +41 -0
  28. data/db/migrate/20150712132226_add_users.rb +41 -0
  29. data/lib/tasks/we_bridge_rails_engine_langs_tasks.rake +4 -0
  30. data/lib/we_bridge_rails_engine_users.rb +16 -0
  31. data/lib/we_bridge_rails_engine_users/application_controller.rb +41 -0
  32. data/lib/we_bridge_rails_engine_users/engine.rb +13 -0
  33. data/lib/we_bridge_rails_engine_users/provider_settings.rb +76 -0
  34. data/lib/we_bridge_rails_engine_users/version.rb +3 -0
  35. data/spec/controllers/sessions_controller_spec.rb +95 -0
  36. data/spec/controllers/users_controller_spec.rb +182 -0
  37. data/spec/dummy/README.rdoc +28 -0
  38. data/spec/dummy/Rakefile +6 -0
  39. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  40. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  41. data/spec/dummy/app/controllers/application_controller.rb +8 -0
  42. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  43. data/spec/dummy/app/views/layouts/application.html.builder +14 -0
  44. data/spec/dummy/bin/bundle +3 -0
  45. data/spec/dummy/bin/rails +4 -0
  46. data/spec/dummy/bin/rake +4 -0
  47. data/spec/dummy/bin/setup +29 -0
  48. data/spec/dummy/config.ru +4 -0
  49. data/spec/dummy/config/application.rb +28 -0
  50. data/spec/dummy/config/boot.rb +5 -0
  51. data/spec/dummy/config/database.yml +25 -0
  52. data/spec/dummy/config/environment.rb +5 -0
  53. data/spec/dummy/config/environments/development.rb +41 -0
  54. data/spec/dummy/config/environments/production.rb +79 -0
  55. data/spec/dummy/config/environments/test.rb +42 -0
  56. data/spec/dummy/config/initializers/assets.rb +11 -0
  57. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  58. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  59. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  60. data/spec/dummy/config/initializers/inflections.rb +16 -0
  61. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  62. data/spec/dummy/config/initializers/provider_settings.rb +2 -0
  63. data/spec/dummy/config/initializers/session_store.rb +3 -0
  64. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  65. data/spec/dummy/config/locales/en.yml +23 -0
  66. data/spec/dummy/config/omniauth.yml +63 -0
  67. data/spec/dummy/config/omniauth.yml.org +63 -0
  68. data/spec/dummy/config/routes.rb +56 -0
  69. data/spec/dummy/config/secrets.yml +22 -0
  70. data/spec/dummy/db/development.sqlite3 +0 -0
  71. data/spec/dummy/db/migrate/20150803101150_create_langs.rb +20 -0
  72. data/spec/dummy/db/schema.rb +134 -0
  73. data/spec/dummy/db/test.sqlite3 +0 -0
  74. data/spec/dummy/log/development.log +6092 -0
  75. data/spec/dummy/log/test.log +17718 -0
  76. data/spec/dummy/public/404.html +67 -0
  77. data/spec/dummy/public/422.html +67 -0
  78. data/spec/dummy/public/500.html +66 -0
  79. data/spec/dummy/public/favicon.ico +0 -0
  80. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/95kd6PNg5I5Dn8j-ds2kESZ4yqJWDlUtJlRkBYcHG9I.cache +2 -0
  81. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/9HedZDeYq2v6HBA9bD890T4cGZibttejhDq0xfEW1OA.cache +0 -0
  82. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Cgic9Tyvkk6sqvxCRHMOht8-YWqOpKEbwWLaLUhtCu8.cache +1 -0
  83. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/DztYUoD64LBf1ciKDNbwfU3ggD7rYJ4R0V_4HPJxzL4.cache +1 -0
  84. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/EQFBBT0dblIxqvZw8BbpahKH5sRVDrYirvYcxKXzg6s.cache +0 -0
  85. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/G4HidZB-L5zKNezfe7O20FU58YFyoibIF0zyMpkigNA.cache +1 -0
  86. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/H5b9tPX4ofo6fe6MRg91ChMHmowlsYkfUKJ9b0NUPIU.cache +3 -0
  87. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/HYpkPupwGozKHs5qChj3sJ-IhRP-YDSiqc-n_hQB1RU.cache +1 -0
  88. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/N4s9e38lth9IeIVQYEn7L9iPWJJEt_FeNaWXgogeW80.cache +1 -0
  89. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/OvqhBxVGrgbFQCuriofYnoMd-Hh6MyK7cCQHpSQ6mY8.cache +1 -0
  90. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Px2rpH6lCQmniOcJktyX-jHQL2GJFj42xgRDMwftICg.cache +0 -0
  91. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/TFk4N5unhxWMiNeFWRf2BmB7KZ2y9c6v4RR7SWHFSl8.cache +0 -0
  92. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/To7LnOAuTthN8xMQdWQRC_bDQ1AeR2Jt1SihvBvu7VM.cache +1 -0
  93. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/Tuk6Xmd6rNalBiAHW2q9yxztUsaXh6vGBN4kuwW4coo.cache +2 -0
  94. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/UthTiMoUK3z7QvIjgYJBlSTzwZ37UE-dam-92yUeRlg.cache +1 -0
  95. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/VhMjuakubXLw9TGrYLMTshl1haIqjdUQDFmrtWqFg48.cache +2 -0
  96. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/W6OPXh5hmWxHo1cCFc6MpmejeEJM-OWXJkmXVnoDdjk.cache +1 -0
  97. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/ivn9YXCSjX-45u61mNupKlBqHNTDKvF7tsbBnXjtu3o.cache +1 -0
  98. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/iyOlCOrvKIBBbvSO3lENE8lJeeFJpDFUKEP4NAUTizg.cache +0 -0
  99. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/j7FsLjc9QBY0x2gZy--i0nskAf-2VCkQ5tCr7M1FKww.cache +0 -0
  100. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/kR7RRgmwH5OahOaSgGVRid1-zpVfnzh9ktcpTc2r8U8.cache +1 -0
  101. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/mAcPZ6Lxmw7lRLF2rOOauuET5gBKl9QaZJgnOkL56Uw.cache +2 -0
  102. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/mOtV0PLRbjn4_sQL0ZHsuAv79ctsBmFq0tLYtQFngZs.cache +1 -0
  103. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/msJs71sOQgd6VP4kducGvRsZ3uZNW4d_vksrGcVZtH4.cache +2 -0
  104. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/pCDWkYCgTWLKByBqi8TDJneTltLoW9rReMGsBiGm9Uo.cache +0 -0
  105. data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/pOOmld85ShNKx5kGi9BubXdV_VZJntx0EoTivl0-bBM.cache +1 -0
  106. data/spec/dummy/tmp/pids/server.pid +1 -0
  107. data/spec/factories/users.rb +6 -0
  108. data/spec/helpers/users_helper_spec.rb +15 -0
  109. data/spec/models/user_spec.rb +5 -0
  110. data/spec/omniauth.yml +63 -0
  111. data/spec/rails_helper.rb +54 -0
  112. data/spec/routing/users_routing_spec.rb +31 -0
  113. data/spec/spec_helper.rb +95 -0
  114. data/spec/views/users/edit.html.builder_spec.rb +16 -0
  115. data/spec/views/users/index.html.builder_spec.rb +16 -0
  116. data/spec/views/users/new.html.builder_spec.rb +14 -0
  117. data/spec/views/users/show.html.builder_spec.rb +13 -0
  118. metadata +383 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bc7a50b8b87213811b77f8cb7c7d97d6702e503e
4
+ data.tar.gz: c99dd8750ffc201199e8155f6cfa18779d081c49
5
+ SHA512:
6
+ metadata.gz: 8243a0de891c2a6fa67631a226754d6084a9b7d06d9e830a9629a656c583e3c62c914b3a7c1e9e181e20d86523ebe6d2df182901ed3f81904b39c7c2344955be
7
+ data.tar.gz: f617d1bf2a045e2be9bc38329f5054178be90f1c5ffd17e0618eb4cae3be1133aed88a8cd34e97e91e11c37a9796dbfd10915c2c4ab86a862597b2db57319281
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Shinjiro Itagaki
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = WeBridgeRailsEngineUsers
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'WeBridgeRailsEngineUsers'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,82 @@
1
+ class SessionsController < ApplicationController
2
+
3
+ # 各プロバイダごとのログイン用urlを返す
4
+ def login
5
+ @providers = []
6
+ WeBridgeRailsEngineUsers::ProviderSettings.availables do |name|
7
+ @providers << {url: WeBridgeRailsEngineUsers::ProviderSettings.request_path(name), display: name.to_s.capitalize }
8
+ end
9
+ end
10
+
11
+ def callback
12
+ auth = request.env['omniauth.auth']
13
+ user = nil
14
+ if account = UserAccount.where(provider: auth['provider'], uid: auth['uid']).first
15
+ user = callback_if_account_found(account,auth)
16
+ else
17
+ user = callback_if_account_not_found(auth)
18
+ end
19
+ set_user_id(user.id) if user && !logged_in?
20
+ if user
21
+ else
22
+ end
23
+ ensure
24
+ redirect_to(session[:redirect_to] || root_path) and return
25
+ end
26
+
27
+ def callback_if_account_found(account,auth)
28
+ if logged_in?
29
+ if account.user && account.user_id != current_user.id
30
+ # 既に他のユーザーが使っている
31
+ # ユーザーが切り替わるようにしてもいいような気がするかもしれないが、セキュリティ上のリスクを考慮して許可しないようにしている。
32
+ # 例えば、あるユーザーAは、googleアカウントとtwitterアカウントの両方でログイン可能であり、かつgoogleアカウントは他社との共有のアカウント、twitterアカウントは自分だけが使える場合、googleのアカウントでログインできる人ならだれでもAになりすますことができてしまうので危険。しかもAはそのことに気が付かない可能性が高い
33
+ # error403 "#{account.provider} is used by other user."
34
+ redirect_to root_path
35
+ return nil
36
+ # ログインユーザーが切り替わる
37
+ # account.user
38
+ end
39
+ current_user
40
+ else
41
+ user = account.user
42
+ if !user # if account is exists but user is deleted
43
+ user = self.class.create_user_by_auth(auth)
44
+ account.update(user_id: user.id) if account.user_id != user.id
45
+ end
46
+ user
47
+ end
48
+ end
49
+
50
+ def callback_if_account_not_found(auth)
51
+ user = nil
52
+ UserAccount.transaction do
53
+ if logged_in?
54
+ user = current_user
55
+ else
56
+ user = self.class.create_user_by_auth(auth)
57
+ user.text.update!(nick_name: auth.info[:name])
58
+ end
59
+ UserAccount.create_with_omniauth!(auth, user.id)
60
+ end
61
+ user
62
+ end
63
+
64
+ def self.create_user_by_auth(auth)
65
+ User.create!(email: auth.info[:email], user_img_url: auth.info[:image], lang_id: Lang[I18n.locale].id)
66
+ end
67
+
68
+ def failure
69
+ flash[:notice]='login failed'
70
+ redirect_to action: :login
71
+ end
72
+
73
+ # GET /users/logout
74
+ def logout
75
+ set_user_id(nil)
76
+ # flash[:notice]=(logged_in? ? "logout" : "not logged in")
77
+ # flash[:status]=:ok
78
+ # render status: :ok, location: root_path
79
+ # request.referrer[:redirect_to] ||
80
+ redirect_to(params["redirect_to"] || root_path) and return
81
+ end
82
+ end
@@ -0,0 +1,9 @@
1
+ require 'we_bridge/auto_view_helper/controller'
2
+ class UsersController < ApplicationController
3
+ include WeBridge::AutoViewHelper::Controller
4
+ set_model User
5
+ before_action only: [:edit,:update,:destroy] do
6
+ login_required
7
+ check_current_user(@record)
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ module UsersHelper
2
+ end
@@ -0,0 +1,13 @@
1
+ require 'activerecord/mlang'
2
+ class Person < ActiveRecord::Base
3
+ include ActiveRecord::Mlang
4
+ has_many :names, ->(){ order(revision: :desc) }, class_name: "PersonName"
5
+
6
+ def name
7
+ if nm = names.first
8
+ nm.name
9
+ else
10
+ nil
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ require 'activerecord/mlang'
2
+ class PersonName < ActiveRecord::Base
3
+ belongs_to :person
4
+ include ActiveRecord::Mlang
5
+ text_attrs :name,:full_name,:first_name,:first_name_pron,:last_name,:last_name_pron,:nick_name,:nick_name_pron
6
+ end
@@ -0,0 +1,24 @@
1
+ require 'activerecord/mlang'
2
+ class PersonNameText < ActiveRecord::Base
3
+ include ActiveRecord::Mlang::Text
4
+
5
+ include Accessable
6
+ set_accessible_attrs :first_name,:first_name_pron,:last_name,:last_name_pron,:nick_name,:nick_name_pron
7
+
8
+ def full_name
9
+ (if self.lang.east?
10
+ [self.last_name,self.first_name]
11
+ else
12
+ [self.first_name,self.last_name]
13
+ end).join(" ")
14
+ end
15
+
16
+ def name
17
+ fn = self.full_name.to_s
18
+ if fn.empty?
19
+ fn
20
+ else
21
+ self.nick_name
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,2 @@
1
+ class PersonStatus < ActiveRecord::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ require 'activerecord/mlang'
2
+ class PersonText < ActiveRecord::Base
3
+ include ActiveRecord::Mlang::Text
4
+ end
@@ -0,0 +1,12 @@
1
+ require 'action_view/helpers/auto_tag_helper/form_info'
2
+ require 'activerecord/mlang'
3
+ require 'we_bridge_rails_engine_langs'
4
+ class User < ActiveRecord::Base
5
+ include ActiveRecord::Mlang
6
+ include ActionView::Helpers::AutoTagHelper::FormInfo
7
+ belongs_to :lang
8
+ set_accessible_attrs :email,:user_img_url,:lang_id
9
+ def __display__
10
+ self.text(self.lang_id).try(:__display__) || self.email
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ class UserAccount < ActiveRecord::Base
2
+ belongs_to :user
3
+ def self.create_with_omniauth!(auth,user_id)
4
+ create! do |user_account|
5
+ user_account.user_id = user_id
6
+ user_account.provider = auth['provider']
7
+ user_account.uid = auth['uid']
8
+ info = auth["info"] || {}
9
+ user_account.nickname = info['nickname']
10
+ user_account.name = info['name']
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'activerecord/mlang'
2
+ require 'action_view/helpers/auto_tag_helper/form_info'
3
+ class UserText < ActiveRecord::Base
4
+ include ActiveRecord::Mlang::Text
5
+ include ActionView::Helpers::AutoTagHelper::FormInfo
6
+ belongs_to :person
7
+ belongs_to :lang
8
+ set_accessible_attrs :nick_name, :nick_name_pron
9
+ def __display__
10
+ self.nick_name
11
+ end
12
+ end
13
+
@@ -0,0 +1,23 @@
1
+ markup do |m|
2
+ m.section do
3
+ if logged_in?
4
+ m.h2 "user info"
5
+ m.div style: "width: 64px; height:64px; background-size: contain; background-repeat: no-repeat; background-image: url(#{current_user.user_img_url});" if current_user.user_img_url.present?
6
+ m.div do
7
+ m.a current_user.try(:__display__), href: user_path(id: current_user.id)
8
+ end
9
+ m.a "logout", href: logout_path
10
+ else
11
+ m.h2 "login by"
12
+ # m << render('layouts/form')
13
+ m.ul do
14
+ @providers.each do |p|
15
+ m.li do
16
+ m.a p[:display].to_s, href: p[:url]
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,14 @@
1
+ form_for @user do |f|
2
+ markup{|m|
3
+ if @user.errors.any?
4
+ #error_explanation
5
+ m.h2 "#{pluralize(@user.errors.count, "error")} prohibited this user from being saved:"
6
+ m.ul do
7
+ @user.errors.full_messages.each do |message|
8
+ m.li message
9
+ end
10
+ end
11
+ end
12
+ m << f.submit
13
+ }.html_safe
14
+ end
@@ -0,0 +1 @@
1
+ edit_common @record, user_path(id: @record), back_path: users_path, show_path: user_path(id: @record)
@@ -0,0 +1 @@
1
+ index_common(@records, show_path: ->(record){ user_path(id: record.id)}, edit_path: ->(record){ edit_user_path(record) }, new_path: nil )
@@ -0,0 +1 @@
1
+ new_common(@record, users_path, back_path: users_path)
@@ -0,0 +1 @@
1
+ show_common @record, show_path: user_path(id: @record), back_path: users_path, edit_path: edit_user_path(id: @record)
data/config/routes.rb ADDED
@@ -0,0 +1,14 @@
1
+ Rails.application.routes.draw do
2
+ root 'sessions#login'
3
+
4
+ get 'logout' => 'sessions#logout'
5
+ settings = WeBridgeRailsEngineUsers::ProviderSettings
6
+ settings.availables do |name|
7
+ get settings.request_path(name), as: settings.auth_as(name)
8
+ get settings.callback_path(name) => "sessions#callback", as: settings.auth_callback_as(name), provider: name
9
+ end
10
+
11
+ match '/auth/failure' => 'sessions#failure', via: :get
12
+
13
+ resources :users,only: [:index,:show,:edit,:update,:destroy]
14
+ end
@@ -0,0 +1,12 @@
1
+ class AddSessionsTable < ActiveRecord::Migration
2
+ def change
3
+ create_table :sessions do |t|
4
+ t.string :session_id, :null => false
5
+ t.text :data
6
+ t.timestamps
7
+ end
8
+
9
+ add_index :sessions, :session_id, :unique => true
10
+ add_index :sessions, :updated_at
11
+ end
12
+ end
@@ -0,0 +1,41 @@
1
+ class CreatePeople < ActiveRecord::Migration
2
+ def change
3
+ create_table :people do |t|
4
+ t.integer :sex, default: 1 , null: false
5
+ t.integer :birth_year, null: false, default: 0
6
+ t.integer :birth_month, null: false, default: 0
7
+ t.integer :birth_day, null: false, default: 0
8
+ t.string :blood_type
9
+ t.integer :created_by, null: false
10
+ t.integer :updated_by, null: false
11
+ t.timestamps
12
+ end
13
+
14
+ create_table :person_texts do |t|
15
+ t.integer :parent_id, null: false
16
+ t.integer :lang_id, null: false
17
+ t.integer :created_by, null: false
18
+ t.integer :updated_by, null: false
19
+ t.timestamps
20
+ end
21
+ add_index :person_texts, [:parent_id,:lang_id], unique: true
22
+
23
+ create_table :person_names do |t|
24
+ t.integer :person_id, null: false
25
+ t.integer :revision, null: false, default: 0
26
+ t.date :modified_on, null: false
27
+ t.timestamps
28
+ end
29
+ add_index :person_names, [:person_id,:revision], unique: true
30
+
31
+ create_table :person_name_texts do |t|
32
+ t.integer :parent_id, null: false
33
+ t.integer :lang_id, null: false
34
+ t.string :first_name, null: true
35
+ t.string :first_name_pron, null: true
36
+ t.string :last_name, null: true
37
+ t.string :last_name_pron, null: true
38
+ end
39
+ add_index :person_name_texts, [:parent_id,:lang_id], unique: true, name: :idx_person_name_texts
40
+ end
41
+ end