mongo_grid 0.2.6 → 0.2.7

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: eaaf801a15cf6a1c400fc477e72a2b8ddd2aff78
4
- data.tar.gz: 885ad7f222cad01171aa333f6d63e4ddf4c42a04
3
+ metadata.gz: 764fa1a431b7ad06df6484ddaa4f68d3fba3bb39
4
+ data.tar.gz: 01a8520a6a3867a742748980913f0780403be89b
5
5
  SHA512:
6
- metadata.gz: 4b9396ae097514e6df16d181263216caa947401a084aa6dbe9d7c7eb93b04a32994d0398de003bc0a8f2c142b662b4fb71dfa7328b23af35cbbeb66c10039e92
7
- data.tar.gz: 9ebf0cc33dd29c9800c94d2ad99ceddd53f5a91d6b1792bc7da6f69f4e538e5f1e8f44fc7dfe334ff56937a1821aa910c960015245f98281290e9a75470310cd
6
+ metadata.gz: a2842fe9ffe3021568bec66e8a21c8cd62c0a7c208182c6010bf2d6841e7ee0ff8f2d85775fb320e4ad6e918d6684f1e58bcc19dbb70078dc0266fd086747780
7
+ data.tar.gz: 8f2678d3d2e49c4fbf8a1631174402322557a2484763b75f2bcf648d530b208fbbc9ea0a4d5cbb4af441885d054b3a1cd40cb47653ce0870f7f3a35b4cf77ade
@@ -1,35 +1,37 @@
1
1
  require "action_controller"
2
- ActionController::Base.class_eval do
3
- def self.need_role(*roles)
4
- roles.each do |role|
5
- eval(%Q(
6
- def need_#{role.to_s}
7
- unless is_#{role.to_s}?
8
- flash[:alert] = "身份不对"
9
- redirect_to root_path and return
10
- end
11
- end
12
- ))
2
+
3
+ ActionController::Base.class_eval do
4
+ def self.need_role(*roles)
5
+ roles.each do |role|
6
+ eval(%Q(
7
+ def need_#{role.to_s}
8
+ unless is_#{role.to_s}?
9
+ flash[:alert] = "身份不对"
10
+ redirect_to login_path and return
11
+ end
13
12
  end
13
+ ))
14
14
  end
15
+ end
15
16
 
16
- def attachit(model,attach = :attach)
17
- unless params[model.to_sym][attach].blank?
18
- if params[:action] == 'update'
19
- old_attach = eval("@#{model}.#{attach.to_s}")
20
- unless old_attach.blank?
21
- id = BSON::ObjectId.from_string(old_attach['grid_id'])
22
- MongoGrid.grid.delete(id)
23
- end
17
+ def attachit(model,attach = :attach,opts = {})
18
+ unless params[model.to_sym][attach].blank?
19
+ if params[:action] == 'update'
20
+ old_attach = eval("@#{model}.#{attach.to_s}")
21
+ unless old_attach.blank?
22
+ id = BSON::ObjectId.from_string(old_attach['grid_id'])
23
+ MongoGrid.grid.delete(id)
24
24
  end
25
- attach=params[model.to_sym][attach]
26
- MongoGrid.uploadtogrid(attach,width: 300)
27
25
  end
26
+ attach=params[model.to_sym][attach]
27
+ MongoGrid.uploadtogrid(attach,opts)
28
28
  end
29
+ end
29
30
 
30
- def pageit
31
- params[:page] ||= 1
32
- per_page = 10
33
- @num=per_page*(params[:page].to_i-1)
34
- end
31
+ def pageit
32
+ params[:page] ||= 1
33
+ per_page = 10
34
+ @num=per_page*(params[:page].to_i-1)
35
35
  end
36
+
37
+ end
@@ -1,7 +1,7 @@
1
1
  module ::Mongoid
2
2
  module Document
3
3
 
4
- %w[logo avatar attach].each do |name|
4
+ %w[logo avatar attach embed].each do |name|
5
5
  module_eval(%Q(
6
6
  def remove_#{name}
7
7
  attach=self.#{name}
@@ -1,3 +1,3 @@
1
1
  module MongoGrid
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_grid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - zxy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-25 00:00:00.000000000 Z
11
+ date: 2017-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: action_controller
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  version: '0'
151
151
  requirements: []
152
152
  rubyforge_project:
153
- rubygems_version: 2.6.11
153
+ rubygems_version: 2.6.8
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: a file upload gem for rails using mongodb