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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36863daefb238f15a3d9f0ad1a9ecd59e1cbdf30
4
- data.tar.gz: face9855059f06f5321be5188c3141c95903424c
3
+ metadata.gz: 0bf96af28f1e531d9d56a84fc4db32eaa2fde4ad
4
+ data.tar.gz: f75a3fe8bf1ebf6267956b924d8417f735980e1d
5
5
  SHA512:
6
- metadata.gz: 2eb85882c8de98dd5a1b0e34f41e74b7609d7465ed502c482980c5081f4f142c477825a58ad85fcc78fcf656417f7797a3aa7523a9a272d835d988f4322314fe
7
- data.tar.gz: f56fac3ea48fe486a18b07a39b0dcaac534e393cdbc348d0e7e710dcd2b18acf1cb910d60aae9a37c167df035b4c6f07532a899197e6754c853698fbab05c92a
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
+
@@ -73,7 +73,7 @@ module Resources
73
73
  end
74
74
 
75
75
  def build_resource
76
- resource_class.new(params_resource)
76
+ resource_class.new()
77
77
  end
78
78
 
79
79
 
@@ -1,3 +1,3 @@
1
1
  module Resources
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-01-25 00:00:00.000000000 Z
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.