回答編集履歴

2

わける

2016/11/04 06:52

投稿

hana-da
hana-da

スコア1728

test CHANGED
@@ -10,6 +10,120 @@
10
10
 
11
11
 
12
12
 
13
+ サーバーの再起動はしましたよね?
14
+
13
- こむずかしいですが [定数の自動読み込みと再読み込み](http://railsguides.jp/autoloading_and_reloading_constants.html) 通常必要な事はだたい書いてあります。
15
+ それダメなら分けてみまか。。。。(helpersにいてあるのもちょっと気になります。。。)
14
16
 
15
17
 
18
+
19
+
20
+
21
+ `app/helpers/o_auth_policy/base.rb`
22
+
23
+ ```ruby
24
+
25
+ module OAuthPolicy
26
+
27
+ class Base
28
+
29
+ attr_reader :provider, :uid, :name, :nickname, :email, :url, :image_url,
30
+
31
+ :description, :other, :credentials, :raw_info
32
+
33
+ end
34
+
35
+ end
36
+
37
+ ```
38
+
39
+
40
+
41
+ `app/helpers/o_auth_policy/facebook.rb`
42
+
43
+ ```ruby
44
+
45
+ module OAuthPolicy
46
+
47
+ class Facebook < OAuthPolicy::Base
48
+
49
+ def initialize(auth)
50
+
51
+ @provider = auth["provider"]
52
+
53
+ @uid = auth["uid"]
54
+
55
+ @name = auth["info"]["name"]
56
+
57
+ @nickname = ""
58
+
59
+ @email = ""
60
+
61
+ @url = "https://www.facebook.com/"
62
+
63
+ @image_url = auth["info"]["image"]
64
+
65
+ @description = ""
66
+
67
+ @credentials = auth["credentials"].to_json
68
+
69
+ @raw_info = auth["extra"]["raw_info"].to_json
70
+
71
+ freeze
72
+
73
+ end
74
+
75
+ end
76
+
77
+ end
78
+
79
+ ```
80
+
81
+
82
+
83
+ `app/helpers/o_auth_policy/twitter.rb`
84
+
85
+ ```ruby
86
+
87
+ module OAuthPolicy
88
+
89
+ class Twitter < OAuthPolicy::Base
90
+
91
+ def initialize(auth)
92
+
93
+ @provider = auth["provider"]
94
+
95
+ @uid = auth["uid"]
96
+
97
+ @name = auth["info"]["name"]
98
+
99
+ @nickname = auth["info"]["nickname"]
100
+
101
+ @email = ""
102
+
103
+ @url = auth["info"]["urls"]["Twitter"]
104
+
105
+ @image_url = auth["info"]["image"]
106
+
107
+ @description = auth["info"]["description"].try(:truncate, 255)
108
+
109
+ @credentials = auth["credentials"].to_json
110
+
111
+ @raw_info = auth["extra"]["raw_info"].to_json
112
+
113
+ freeze
114
+
115
+ end
116
+
117
+ end
118
+
119
+ end
120
+
121
+ ```
122
+
123
+
124
+
125
+ ----
126
+
127
+
128
+
129
+ こむずかしいですが [定数の自動読み込みと再読み込み](http://railsguides.jp/autoloading_and_reloading_constants.html) に通常必要な事はだいたい書いてあります。

1

こむずかしいはなし

2016/11/04 06:52

投稿

hana-da
hana-da

スコア1728

test CHANGED
@@ -3,3 +3,13 @@
3
3
 
4
4
 
5
5
  `app/helpers/o_auth_service/o_auth_policy.rb` を `app/helpers/o_auth_policy.rb` にすればいいような気がします。
6
+
7
+
8
+
9
+ ----
10
+
11
+
12
+
13
+ こむずかしいですが [定数の自動読み込みと再読み込み](http://railsguides.jp/autoloading_and_reloading_constants.html) に通常必要な事はだいたい書いてあります。
14
+
15
+