質問編集履歴
3
ablity\.rbが間違っていました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -72,15 +72,23 @@
|
|
72
72
|
|
73
73
|
```ruby
|
74
74
|
|
75
|
-
class A
|
75
|
+
class Ability
|
76
76
|
|
77
|
-
|
77
|
+
include CanCan::Ability
|
78
78
|
|
79
|
-
# :token_authenticatable, :confirmable,
|
80
79
|
|
81
|
-
# :lockable, :timeoutable and :omniauthable
|
82
80
|
|
81
|
+
def initialize(user)
|
82
|
+
|
83
|
+
if user && user.admin?
|
84
|
+
|
83
|
-
|
85
|
+
can :access, :rails_admin # grant access to rails_admin
|
86
|
+
|
87
|
+
can :manage, :all # allow superadmins to do anything
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
84
92
|
|
85
93
|
end
|
86
94
|
|
2
gitファイルは問題ないかと思います。
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
user\.rbを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -86,4 +86,82 @@
|
|
86
86
|
|
87
87
|
```
|
88
88
|
|
89
|
+
> user.rb
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
|
93
|
+
class User < ApplicationRecord
|
94
|
+
|
95
|
+
# Include default devise modules. Others available are:
|
96
|
+
|
97
|
+
# :confirmable, :lockable, :timeoutable and :omniauthable
|
98
|
+
|
99
|
+
devise :database_authenticatable, :registerable,
|
100
|
+
|
101
|
+
:recoverable, :rememberable, :trackable, :validatable,
|
102
|
+
|
103
|
+
:omniauthable
|
104
|
+
|
105
|
+
has_many :reviews, dependent: :destroy
|
106
|
+
|
107
|
+
has_many :user_images
|
108
|
+
|
109
|
+
mount_uploader :image, ThumbnailUploader
|
110
|
+
|
111
|
+
accepts_nested_attributes_for :user_images
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
class << self
|
116
|
+
|
117
|
+
def find_for_facebook_oauth(auth)
|
118
|
+
|
119
|
+
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
|
120
|
+
|
121
|
+
user.email = auth.info.email
|
122
|
+
|
123
|
+
user.password = Devise.friendly_token[0,20]
|
124
|
+
|
125
|
+
user.name = auth.info.name
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
def create_unique_string
|
134
|
+
|
135
|
+
SecureRandom.uuid
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
def create_unique_email
|
142
|
+
|
143
|
+
User.create_unique_string + "@example.com"
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
private
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
def user_params
|
156
|
+
|
157
|
+
params.require(:user).permit(:name, :email, :image, user_images_attributes: [:cover_image])
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
```
|
164
|
+
|
165
|
+
|
166
|
+
|
89
167
|
すみませんが、どうぞよろしくお願いいたします。
|