@@ -42,13 +42,7 @@ $ rake db:migrate
42
42
43
43
Running the generator will do a few things:
44
44
45
- 1 . add the engine routes to your routes.rb:
46
-
47
- ``` ruby
48
- # config/routes.rb
49
- mount Wupee ::Engine , at: " /wupee"
50
- ```
51
- 2 . create <a name =" initializer " >wupee initializer</a >:
45
+ 1 . create <a name =" initializer " >wupee initializer</a >:
52
46
53
47
``` ruby
54
48
# config/initializers/wupee.rb
@@ -67,7 +61,7 @@ Running the generator will do a few things:
67
61
# # logic goes here, returning a boolean
68
62
# end
69
63
```
70
- 3 . create a mailer ` NotificationsMailer ` which inheritates from ` Wupee::NotificationsMailer `
64
+ 2 . create a mailer ` NotificationsMailer ` which inheritates from ` Wupee::NotificationsMailer `
71
65
72
66
``` ruby
73
67
# app/mailers/notifications_mailer.rb
@@ -77,7 +71,7 @@ Running the generator will do a few things:
77
71
end
78
72
```
79
73
80
- 4 . adds wupee to your locale yml file (for email subjects)
74
+ 3 . adds wupee to your locale yml file (for email subjects)
81
75
``` yml
82
76
# config/locales/en.yml
83
77
en :
@@ -168,14 +162,30 @@ You can also use the method `notify` this way:
168
162
## Wupee::Api::NotificationsController
169
163
170
164
The controller have various actions all scoped for the current user:
171
- * ` wupee/api/notifications#index ` : fetch notifications, take an optional parameter ` is_read ` (false by default )
165
+ * ` wupee/api/notifications#index ` : fetch notifications, takes an optional parameter ` scopes ` (example: scopes=read,ordered )
172
166
* ` wupee/api/notifications#show ` : fetch a notification
173
- * ` wupee/api/notifications#mark_as_read ` : mark as read a notification
174
- * ` wupee/api/notifications#mark_all_as_read ` : mark as read all notifications
167
+ * ` wupee/api/notifications#mark_as_read ` : mark a notification as read
168
+ * ` wupee/api/notifications#mark_all_as_read ` : mark all notifications as read
175
169
176
170
To use this controller, define a controller inheriting from ` Wupee::Api::NotificationsController ` , set the routes in your ` config/routes.rb `
177
171
and define a method ` current_user ` which returns the user signed in.
178
172
173
+ Example:
174
+ ``` ruby
175
+ # config/routes.rb
176
+ namespace :api , defaults: { format: :json } do
177
+ resources :notifications , only: [:index , :show ] do
178
+ patch :mark_as_read , on: :member
179
+ patch :mark_all_as_read , on: :collection
180
+ end
181
+ end
182
+
183
+ # app/controllers/api/notifications_controller.rb
184
+ class Api ::NotificationsController < Wupee ::Api ::NotificationsController
185
+ before_action :authenticate_user! # if you are using devise
186
+ end
187
+ ```
188
+
179
189
## Why WUPEE ?
180
190
181
191
** W** hat's ** UP** Sl** EE** de
0 commit comments