mongo_grid 0.2.4 → 0.2.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: 8d438752461a87268c182cc6f8159b50c8f7d467
4
- data.tar.gz: 265d08dddfc43d7f43feae84886cc373c02dd807
3
+ metadata.gz: 0b967f020175148e6e9660e41afe88a24107b524
4
+ data.tar.gz: bdd8ab76393220b35e312d90ee92a4e926871a52
5
5
  SHA512:
6
- metadata.gz: 1b0eb61cd999209e16ef944e1f81f3ab9436721b1c2704ca96fad86788784d4e71c49ec416e6c049d704a8e569a4cc0e24a10e1e589553515f1f99215a6e1db7
7
- data.tar.gz: c35507e0e740e1563fcd35b064db2e4012c9c9e209fca2f5ee4dd587fde7be156a22b2b4d7e44f6681e5bb157399c1462663df6668add54eae0fe3379df709b7
6
+ metadata.gz: b290adb6b358518090d8a47afba2ded797d261d99fa795c83c3277d9ce8f2de061dd7414cf264226a974a39a0193c8e118538b8062a1da64819502012e46c4d4
7
+ data.tar.gz: d954c56e866c6d939986f93b18c3c14d95741ae16342b8dc6e4ae6eb6cec4e3e5d390e93b552fad69ed14dfcf7bcf4363dd50aed484f2938a19209cb5330d891
@@ -0,0 +1,36 @@
1
+ class ActionController::Base
2
+ def self.need_role(*roles)
3
+ roles.each do |role|
4
+ eval(%Q(
5
+ def need_#{role.to_s}
6
+ unless is_#{role.to_s}?
7
+ flash[:alert] = "身份不对"
8
+ redirect_to root_path and return
9
+ end
10
+ end
11
+ ))
12
+ end
13
+ end
14
+
15
+
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
24
+ end
25
+ attach=params[model.to_sym][attach]
26
+ MongoGrid.uploadtogrid(attach,width: 300)
27
+ end
28
+ end
29
+
30
+ def pageit
31
+ params[:page] ||= 1
32
+ per_page = 10
33
+ @num=per_page*(params[:page].to_i-1)
34
+ end
35
+
36
+ end
@@ -1,3 +1,3 @@
1
1
  module MongoGrid
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_grid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - zxy
@@ -112,6 +112,7 @@ files:
112
112
  - bin/console
113
113
  - bin/setup
114
114
  - lib/mongo_grid.rb
115
+ - lib/mongo_grid/action_base.rb
115
116
  - lib/mongo_grid/mongoid.rb
116
117
  - lib/mongo_grid/version.rb
117
118
  - mongo_grid.gemspec
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  version: '0'
136
137
  requirements: []
137
138
  rubyforge_project:
138
- rubygems_version: 2.6.8
139
+ rubygems_version: 2.6.11
139
140
  signing_key:
140
141
  specification_version: 4
141
142
  summary: a file upload gem for rails using mongodb