質問するログイン新規登録

回答編集履歴

2

わける

2016/11/04 06:52

投稿

hana-da
hana-da

スコア1728

answer CHANGED
@@ -4,4 +4,62 @@
4
4
 
5
5
  ----
6
6
 
7
+ サーバーの再起動はしましたよね?
8
+ それでダメなら分けてみますか。。。。(helpersに置いてあるのもちょっと気になりますが。。。。)
9
+
10
+
11
+ `app/helpers/o_auth_policy/base.rb`
12
+ ```ruby
13
+ module OAuthPolicy
14
+ class Base
15
+ attr_reader :provider, :uid, :name, :nickname, :email, :url, :image_url,
16
+ :description, :other, :credentials, :raw_info
17
+ end
18
+ end
19
+ ```
20
+
21
+ `app/helpers/o_auth_policy/facebook.rb`
22
+ ```ruby
23
+ module OAuthPolicy
24
+ class Facebook < OAuthPolicy::Base
25
+ def initialize(auth)
26
+ @provider = auth["provider"]
27
+ @uid = auth["uid"]
28
+ @name = auth["info"]["name"]
29
+ @nickname = ""
30
+ @email = ""
31
+ @url = "https://www.facebook.com/"
32
+ @image_url = auth["info"]["image"]
33
+ @description = ""
34
+ @credentials = auth["credentials"].to_json
35
+ @raw_info = auth["extra"]["raw_info"].to_json
36
+ freeze
37
+ end
38
+ end
39
+ end
40
+ ```
41
+
42
+ `app/helpers/o_auth_policy/twitter.rb`
43
+ ```ruby
44
+ module OAuthPolicy
45
+ class Twitter < OAuthPolicy::Base
46
+ def initialize(auth)
47
+ @provider = auth["provider"]
48
+ @uid = auth["uid"]
49
+ @name = auth["info"]["name"]
50
+ @nickname = auth["info"]["nickname"]
51
+ @email = ""
52
+ @url = auth["info"]["urls"]["Twitter"]
53
+ @image_url = auth["info"]["image"]
54
+ @description = auth["info"]["description"].try(:truncate, 255)
55
+ @credentials = auth["credentials"].to_json
56
+ @raw_info = auth["extra"]["raw_info"].to_json
57
+ freeze
58
+ end
59
+ end
60
+ end
61
+ ```
62
+
63
+ ----
64
+
7
- こむずかしいですが [定数の自動読み込みと再読み込み](http://railsguides.jp/autoloading_and_reloading_constants.html) に通常必要な事はだいたい書いてあります。
65
+ こむずかしいですが [定数の自動読み込みと再読み込み](http://railsguides.jp/autoloading_and_reloading_constants.html) に通常必要な事はだいたい書いてあります。

1

こむずかしいはなし

2016/11/04 06:52

投稿

hana-da
hana-da

スコア1728

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