resources 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +39 -0
- data/lib/resources/manager.rb +1 -1
- data/lib/resources/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bf96af28f1e531d9d56a84fc4db32eaa2fde4ad
|
4
|
+
data.tar.gz: f75a3fe8bf1ebf6267956b924d8417f735980e1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 859dfff9cfd561b2dee3fa56999183c7a89fee9e9d8b3a369d85ff30f17162a26f64fdecf3b20842e70d220f3ec1969968e260b8fcb879bdff0444562c9c7a2c
|
7
|
+
data.tar.gz: 0786fb7b9bd204e118cc8707384cd6880b69759d4dbace1977b5ab2bba8d5a0df7120632731400e1aa827a75a0a7477d858a8166bb7d15a1ff43ea3aa5a60b8b
|
data/README.md
CHANGED
@@ -207,6 +207,44 @@ end
|
|
207
207
|
= f.search_field :name_cont
|
208
208
|
= f.submit
|
209
209
|
```
|
210
|
+
#### **Overriding methods **
|
211
|
+
|
212
|
+
##### **Redirects **
|
213
|
+
|
214
|
+
By default, after any of the REST actions that modify the record (create, update, destroy) **it redirects to the index action** of that controller, but if you define method **`after_#{action_name}_path_for`** that returns a path **it will execute this method and redirect** to that particular path.
|
215
|
+
|
216
|
+
**Example**
|
217
|
+
|
218
|
+
```
|
219
|
+
def after_create_path_for
|
220
|
+
root_url
|
221
|
+
end
|
222
|
+
|
223
|
+
```
|
224
|
+
**NOTE:** After creating the record it will redirect to the **root_url**
|
225
|
+
|
226
|
+
##### **default REST actions**
|
227
|
+
|
228
|
+
If you want to override any of the REST actions, to add any extra logic that you may need, you can just pass a block to the **`save_resource`** or **`destroy_resource`** inside the actions and add your custom logic there.
|
229
|
+
|
230
|
+
**Example**
|
231
|
+
|
232
|
+
```
|
233
|
+
def create
|
234
|
+
save_resource do
|
235
|
+
# Add you complex logic here
|
236
|
+
if resource_saved?
|
237
|
+
flash[:notice] = I18n.t("app.record_successfully_created")
|
238
|
+
redirect_to root_url and return
|
239
|
+
else
|
240
|
+
render action: :new
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
```
|
246
|
+
|
247
|
+
**NOTE:** Remember that you can make use of the **`resource_saved?`** method to know if the record has been saved
|
210
248
|
|
211
249
|
#### **GLOBAL CONFIGURATION **
|
212
250
|
|
@@ -228,3 +266,4 @@ end
|
|
228
266
|
Copyright (c) 2015 Emilio Forrer. See LICENSE.txt for further details.
|
229
267
|
|
230
268
|
|
269
|
+
|
data/lib/resources/manager.rb
CHANGED
data/lib/resources/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emilio Forrer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: It's a gem that help's you to create CRUD controllers for your models
|
14
14
|
in a very fast and flexible way.
|