effective_resources 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4fe2a46aac6809ee12c839f38125664f50ac64e
4
- data.tar.gz: 4e022c5747750828080cc786ae1a1e5ce8474668
3
+ metadata.gz: b903d872e935f454fad70eb26bc2d355b5034785
4
+ data.tar.gz: d7620fe963d37d8b9e7ef5902084e36f45bfddff
5
5
  SHA512:
6
- metadata.gz: 4c7cb536f94b69024d8af6e206f71a61c3eec482d53af71c713899e64d0f0ca079a85120f2c106ac9e68b956169f652ecfb35c15e57201195643f6ca01f9e1f6
7
- data.tar.gz: 2fe867ec72221295e0570877c177f67b7f5e33d45d5919eca94578fe3e0c5fd604accec60c7a9a527ca2e023b9121a3b086cb11823310f2754b4085566a469b6
6
+ metadata.gz: e7d794194d53f98734483054b3e93a9bf8aedcae82fd430f7d32753bf2688325cabecadba0e0003dde127715b4d13a94e3016a5a95049dded9b9e7ccf920839e
7
+ data.tar.gz: c4c1b0472b1e2533ae686651ff673842f8d6229b95fcaa0711f1f4a7934d2ae23d3be5ac85a2b560e5361f67bd9c094decde00c8cdc53435ff197824b9d9abf4
@@ -191,10 +191,10 @@ module Effective
191
191
  self.resource ||= resource_scope.new
192
192
 
193
193
  @page_title ||= "New #{resource_name.titleize}"
194
- EffectiveResources.authorize!(self, :create, resource)
195
194
 
196
195
  action = commit_action[:action]
197
196
  EffectiveResources.authorize!(self, action, resource) unless action == :save
197
+ EffectiveResources.authorize!(self, :create, resource) if action == :save
198
198
 
199
199
  resource.assign_attributes(send(resource_params_method_name))
200
200
  resource.created_by ||= current_user if resource.respond_to?(:created_by=)
@@ -236,10 +236,10 @@ module Effective
236
236
  self.resource ||= resource_scope.find(params[:id])
237
237
 
238
238
  @page_title = "Edit #{resource}"
239
- EffectiveResources.authorize!(self, :update, resource)
240
239
 
241
240
  action = commit_action[:action]
242
241
  EffectiveResources.authorize!(self, action, resource) unless action == :save
242
+ EffectiveResources.authorize!(self, :update, resource) if action == :save
243
243
 
244
244
  resource.assign_attributes(send(resource_params_method_name))
245
245
 
@@ -248,7 +248,7 @@ module Effective
248
248
  flash[:success] ||= flash_success(resource, action)
249
249
 
250
250
  format.html { redirect_to(resource_redirect_path) }
251
- format.js { } # update.js.erb
251
+ format.js { reload_resource } # update.js.erb
252
252
  else
253
253
  flash.now[:danger] ||= flash_danger(resource, action)
254
254
 
@@ -332,7 +332,10 @@ module Effective
332
332
 
333
333
  resource_klass.transaction do
334
334
  begin
335
- resource.public_send("#{action}!") || raise("failed to #{action} #{resource}")
335
+ if resource.public_send("#{action}!") == false
336
+ raise("failed to #{action} #{resource}")
337
+ end
338
+
336
339
  yield if block_given?
337
340
  run_callbacks(:resource_save)
338
341
  return true
@@ -349,6 +352,10 @@ module Effective
349
352
  false
350
353
  end
351
354
 
355
+ def reload_resource
356
+ self.resource = resource_scope.find(params[:id])
357
+ end
358
+
352
359
  # Should return a new resource based on the passed one
353
360
  def duplicate_resource(resource)
354
361
  resource.dup
@@ -3,7 +3,3 @@
3
3
 
4
4
  EffectiveBootstrap.remote_form_payload = $("<%= j render_resource_form(resource) %>");
5
5
  EffectiveBootstrap.remote_form_flash = <%= raw flash.to_json %>;
6
-
7
- <% if flash[:success].blank? %>
8
- EffectiveBootstrap.remote_form_flash_payload = $("<%= j render('flash') %>");
9
- <% end %>
@@ -3,7 +3,3 @@
3
3
 
4
4
  EffectiveBootstrap.remote_form_payload = $("<%= j render_resource_form(resource) %>");
5
5
  EffectiveBootstrap.remote_form_flash = <%= raw flash.to_json %>;
6
-
7
- <% if flash[:success].blank? %>
8
- EffectiveBootstrap.remote_form_flash_payload = $("<%= j render('flash') %>");
9
- <% end %>
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '0.8.4'.freeze
2
+ VERSION = '0.8.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect