has_images 0.1.5 → 0.1.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.
Files changed (3) hide show
  1. data/README.md +11 -0
  2. data/lib/has_images.rb +2 -1
  3. metadata +2 -2
data/README.md CHANGED
@@ -62,7 +62,18 @@ add the following to your config/enviroment.rb
62
62
 
63
63
  ### Imageupload via form
64
64
 
65
+ ### enabling Counter-Cache (since version 0.1.7)
65
66
 
67
+ class User < ActiveRecord::Base
68
+ has_images :styles => {
69
+ :thumb => ["150x100", :jpg]
70
+ },
71
+ :path => ":rails_root/public/images/:attachment/:id_partition/:id_:style.:extension",
72
+ :url => "/images/:attachment/:id_partition/:id_:style.:extension",
73
+ :counter_cache => "images_count"
74
+ end
75
+
76
+ This enables the counter_cache for the user-model. CounterCache is saved in the field "images_count"
66
77
 
67
78
 
68
79
  Copyright (c) 2010 Dennis Meise [Digineo GmbH](http://www.digineo.de/ "Digineo GmbH") , released under the MIT license
data/lib/has_images.rb CHANGED
@@ -8,13 +8,14 @@ module HasImages
8
8
  module ClassMethods
9
9
  # adds has_images to model
10
10
  def has_images(options={})
11
-
11
+ counter_cache = options.delete(:couter_cache) || false
12
12
  # eval is not always evil ;)
13
13
  # we generate a Digineo::Model::Image clase to store the given paperclip configuration in it
14
14
  eval <<-EOF
15
15
  module Digineo::#{self.class_name}
16
16
  class Digineo::#{self.class_name}::Image < Digineo::Image
17
17
  has_attached_file :file, #{options.inspect}
18
+ belongs_to :parentmodel, :counter_cache => #{counter_cache.inspect}
18
19
  end
19
20
  end
20
21
  EOF
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_images
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Meise
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-27 00:00:00 +02:00
12
+ date: 2010-07-15 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency