Coder Social home page Coder Social logo

dm-paperclip's People

Contributors

brianthecoder avatar foysavas avatar fsaravia avatar gix avatar krobertson avatar merbjedi avatar nitsujw avatar okiess avatar pk avatar postmodern avatar rhc2104 avatar serene-dev avatar snusnu avatar solnic avatar xaviershay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dm-paperclip's Issues

Assumes primary key is 'id'

A datamapper model with a PK that is not 'id' can not currently be used as a Paperclip resource.

lib/dm-paperclip/interpolations.rb calls attachment.instance.id at line 103 and 109.

fails valid_assignment? when handling uploads through webrick or mongrel

The problem seems to be that valid_assignment is checking for an instance of File class when webrick/rack/mongrel gives it a Tempfile instance

the following patch fixes the problem

--- lib/dm-paperclip/attachment.rb      2009-08-21 08:50:05.274432152 +1000
+++ lib/dm-paperclip/attachment.rb      2009-08-21 08:58:18.135469700 +1000
@@ -239,7 +239,7 @@

     def valid_assignment? file #:nodoc:
       return true if file.nil?
-      if(file.is_a?(File))
+      if(file.is_a?(::File) or file.is_a?(::Tempfile))
         (file.respond_to?(:original_filename) && file.respond_to?(:content_type))
       elsif(file.is_a?(Mash))
         (file.include?('tempfile') && file.include?('content_type') && file.include?('size') && file.include?('filename'))

most properties like content_type, file_size should be optional

Just as the original gem allows us, it should be possible to have the properties content_type, file_size, updated_at to be optional.

'm now sure what the best way to do this. May be by passing an option like :custom_properties => true to has_attached_file and then it's up to the model to define all properties?

Content type of a file is always identified as application/x-octet-stream

I am running Ubuntu 10.04 till 11.04; sinatra/unicorn/rack; all file content types are identified as application/x-octet-stream; I am unable to verify on other platforms:

I think inside lib / dm-paperclip / attachment.rb line 84 should be modified from content_type to type:
--- OLD
instance_write(:content_type, uploaded_file['content_type'] ? uploaded_file['content_type'].strip : uploaded_file['tempfile'].content_type.to_s.strip)

+++ NEW
instance_write(:content_type, uploaded_file['type'] ? uploaded_file['type'].strip : uploaded_file['tempfile'].content_type.to_s.strip)

dm-validations

very good work, thank you.

Alas, i am trying to use dm-devise and that explicitly warns not to include dm-validations and rely on what's included in dm-active_model (which comes from using dm-rails)

so it looks like things can't work at the moment. Or am i missing something ?
Could dm-paperclip be made to use the active_model validations ?

Using slim with dm-paperclip

When using dm-paperclip with slim (Sinatra app) the slim default options all get set to nil and I get no Method found errors. I since paperclip has options I assume there may be some interference. Any ideas how to resolve this?

Many Syntax Errors on Ruby 1.9.1

[jc@macbookpro ~/Desktop/dm-paperclip]# rake
(in /Users/jc/Desktop/dm-paperclip)
/Users/jc/.rvm/ruby-1.9.1-p243/bin/ruby -I"lib:dm-paperclip" "/Users/jc/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/attachment_test.rb" "test/geometry_test.rb" "test/integration_test.rb" "test/iostream_test.rb" "test/paperclip_test.rb" "test/storage_test.rb" "test/thumbnail_test.rb" 
/Users/jc/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load': /Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:184: invalid multibyte char (US-ASCII) (SyntaxError)
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:184: syntax error, unexpected $undefined
...ame).returns("sheep_say_b?.png\r\n")
...                               ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:185: syntax error, unexpected tIDENTIFIER, expecting keyword_end
      @not_file.expects(:content_type).returns("image/png\r\n")
                                                     ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:185: syntax error, unexpected $undefined, expecting keyword_end
      @not_file.expects(:content_type).returns("image/png\r\n")
                                                          ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:197: syntax error, unexpected tIDENTIFIER, expecting keyword_end
    should "remove strange letters and replace with underscore (_)" do
                  ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:197: syntax error, unexpected tSTRING_BEG, expecting keyword_end
    should "remove strange letters and replace with underscore (_)" do
                                                                   ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:198: syntax error, unexpected tIDENTIFIER, expecting keyword_end
      assert_equal "sheep_say_b_.png", @dummy.avatar.original_filename
                                ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:202: syntax error, unexpected tCONSTANT, expecting keyword_end
  context "An attachment" do
             ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:205: syntax error, unexpected ':', expecting keyword_end
        :path => ":merb_root/tmp/:attachment/:cl...
                   ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:205: syntax error, unexpected tSYMBEG
...t/:class/:style/:id/:basename.:extension"
...                               ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:207: syntax error, unexpected tIDENTIFIER, expecting keyword_end
      FileUtils.rm_rf("tmp")
                          ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:213: syntax error, unexpected tIDENTIFIER, expecting keyword_end
                                 "fixtures",
                                          ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:214: syntax error, unexpected tINTEGER, expecting keyword_end
                                 "5k.png"))
                                   ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:217: syntax error, unexpected tIDENTIFIER, expecting keyword_end
    should "raise if there are not the correct...
                 ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:217: syntax error, unexpected tIDENTIFIER, expecting '('
...uld "raise if there are not the correct columns when you try...
...                               ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:217: syntax error, unexpected keyword_when, expecting keyword_end
...re not the correct columns when you try to assign" do
...                               ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:224: syntax error, unexpected keyword_return, expecting keyword_end
    should "return its default_url when no file assigned" do
                  ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:224: syntax error, unexpected keyword_when, expecting keyword_end
    should "return its default_url when no file assigned" do
                                       ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:226: syntax error, unexpected tSTRING_BEG, expecting keyword_end
      assert_equal "/avatars/original/missing.png", @attachment.url
                                                  ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:227: syntax error, unexpected tSTRING_BEG, expecting keyword_end
      assert_equal "/avatars/blah/missing.png", @attachment.url(:blah)
                                              ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:230: syntax error, unexpected tIDENTIFIER, expecting keyword_end
    context "with a file assigned in the database" do
                 ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:230: syntax error, unexpected keyword_in, expecting keyword_end
    context "with a file assigned in the database" do
                                    ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:233: syntax error, unexpected tIDENTIFIER, expecting keyword_end
...ar_content_type).returns("image/png")
...                               ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:233: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
...ntent_type).returns("image/png")
...                               ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:240: syntax error, unexpected keyword_return, expecting keyword_end
      should "return a correct url even if the file does not exist" do
                    ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:240: syntax error, unexpected tIDENTIFIER, expecting '('
      should "return a correct url even if the file does not exist" do
                                                                  ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:245: syntax error, unexpected tIDENTIFIER, expecting keyword_end
      should "make sure the updated_at mtime is...
                  ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:245: syntax error, unexpected keyword_in, expecting keyword_end
...sure the updated_at mtime is in the url if it is defined" do
...                               ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:249: syntax error, unexpected tIDENTIFIER, expecting keyword_end
      context "with the updated_at field removed" do
                   ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:254: syntax error, unexpected tIDENTIFIER, expecting keyword_end
        should "only return the url without the u...
                    ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:254: void value expression
...        should "only return the url without the updated_at w...
...                               ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:254: syntax error, unexpected keyword_when, expecting keyword_end
...url without the updated_at when sent #url" do
...                               ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:301: syntax error, unexpected keyword_do_block, expecting keyword_end
              [:large, :medium, :small].each do |style|
                                               ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:311: syntax error, unexpected keyword_do_block, expecting keyword_end
               [:small, 32, 32, "JPEG"]].each do |style|
                                                ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:328: syntax error, unexpected keyword_do_block, expecting keyword_end
...tachment.styles.keys.collect do |style|
...                               ^
/Users/jc/Desktop/dm-paperclip/test/attachment_test.rb:343: syntax error, unexpected keyword_end, expecting $end
    from /Users/jc/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `block in <main>'
    from /Users/jc/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
    from /Users/jc/.rvm/gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `<main>'
rake aborted!
Command failed with status (1): [/Users/jc/.rvm/ruby-1.9.1-p243/bin/ruby -I...]

(See full trace by running task with --trace)
[jc@macbookpro ~/Desktop/dm-paperclip]# ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin10.0.0]
[jc@macbookpro ~/Desktop/dm-paperclip]# 

Can't use validator with Rails 3.2 and DataMapper 1.2

I'm trying to use dm-validators:

config.use_dm_validations = true

But, I end up with the following error:

$path/gems/dm-core-1.2.0/lib/dm-core/model/relationship.rb:372:in method missing': undefined methodopts_from_validator_args' for MyClass:Class (NoMethodError).

This is my gemfile:

source 'https://rubygems.org'

RAILS_VERSION = '~> 3.2.3'

#gem 'rails', '3.2.3'
gem 'activesupport', RAILS_VERSION, :require => 'active_support'
gem 'actionpack', RAILS_VERSION, :require => 'action_pack'
gem 'actionmailer', RAILS_VERSION, :require => 'action_mailer'
gem 'activeresource', RAILS_VERSION, :require => 'active_resource'
gem 'railties', RAILS_VERSION, :require => 'rails'
gem 'tzinfo', '~> 0.3.32'

gem 'dm-rails', '~> 1.2.1'
gem 'dm-sqlite-adapter', group: [:development, :test]
gem 'dm-postgres-adapter', group: [:production]
# You can use any of the other available database adapters.
# This is only a small excerpt of the list of all available adapters
# Have a look at
#
# http://wiki.github.com/datamapper/dm-core/adapters
# http://wiki.github.com/datamapper/dm-core/community-plugins
#
# for a rather complete list of available datamapper adapters and plugins
gem 'dm-migrations'
gem 'dm-types'
gem 'dm-validations'
gem 'dm-constraints'
gem 'dm-transactions'
gem 'dm-aggregates'
gem 'dm-timestamps'
gem 'dm-observer'
gem 'dm-core'
gem 'dm-serializer'
gem 'dm-constraints'

gem 'dm-devise',       '~> 2.1.0'
gem 'data_mapper'
gem 'dm-paperclip', git: 'https://github.com/krobertson/dm-paperclip.git'

gem 'responders'

gem "haml-rails"

gem "heroku"
gem "omniauth-facebook"
gem 'aws-s3'

# FaceBook
gem 'koala'

# MailChimp
gem 'hominid', '~> 3.0'

gem 'jquery-rails'

gem 'friendly_id', "~> 4.0"

group :assets do
  gem 'sass-rails', "  ~> 3.1"
  gem 'coffee-rails', "~> 3.1"
  gem 'uglifier', ">= 1.0.3"
end

group :development do
  gem "taps"
end

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
  gem 'ffaker'  
  gem 'rspec-rails'
  gem 'shoulda-matchers'
  gem 'cucumber-rails'
  gem 'capybara'
  gem 'launchy'
  gem 'guard-rspec'
  gem 'guard-livereload'
  gem 'growl'
  gem 'factory_girl'
  gem 'factory_girl_generator'
  gem 'simplecov', require: false
end

group :production do
  gem "unicorn"
  gem "pg"
  gem "execjs"
  gem 'newrelic_rpm'
  gem 'dalli'
end

And the Gemfile.lock:

GIT
  remote: https://github.com/krobertson/dm-paperclip.git
  revision: aabad04f2a65e8f628e7e838d9bd3e1c9c39914d
  specs:
    dm-paperclip (2.4.1)

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.3)
      actionpack (= 3.2.3)
      mail (~> 2.4.4)
    actionpack (3.2.3)
      activemodel (= 3.2.3)
      activesupport (= 3.2.3)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.1)
      rack (~> 1.4.0)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.1.2)
    activemodel (3.2.3)
      activesupport (= 3.2.3)
      builder (~> 3.0.0)
    activeresource (3.2.3)
      activemodel (= 3.2.3)
      activesupport (= 3.2.3)
    activesupport (3.2.3)
      i18n (~> 0.6)
      multi_json (~> 1.0)
    addressable (2.2.8)
    ansi (1.4.2)
    aws-s3 (0.6.3)
      builder
      mime-types
      xml-simple
    bcrypt-ruby (3.0.1)
    builder (3.0.0)
    capybara (1.1.2)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 0.1.4)
    childprocess (0.3.2)
      ffi (~> 1.0.6)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.3.3)
    cucumber (1.2.0)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.3)
      gherkin (~> 2.10.0)
      json (>= 1.4.6)
    cucumber-rails (1.3.0)
      capybara (>= 1.1.2)
      cucumber (>= 1.1.8)
      nokogiri (>= 1.5.0)
    dalli (2.0.5)
    data_mapper (1.2.0)
      dm-aggregates (~> 1.2.0)
      dm-constraints (~> 1.2.0)
      dm-core (~> 1.2.0)
      dm-migrations (~> 1.2.0)
      dm-serializer (~> 1.2.0)
      dm-timestamps (~> 1.2.0)
      dm-transactions (~> 1.2.0)
      dm-types (~> 1.2.0)
      dm-validations (~> 1.2.0)
    data_objects (0.10.8)
      addressable (~> 2.1)
    devise (2.1.0)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.0.7)
      railties (~> 3.1)
      warden (~> 1.1.1)
    diff-lcs (1.1.3)
    dm-active_model (1.2.1)
      activemodel (~> 3.0)
      dm-core (~> 1.2.0)
    dm-aggregates (1.2.0)
      dm-core (~> 1.2.0)
    dm-constraints (1.2.0)
      dm-core (~> 1.2.0)
    dm-core (1.2.0)
      addressable (~> 2.2.6)
    dm-devise (2.1.0)
      devise (>= 1.3)
      dm-core (>= 1.0.2, < 2.0)
      dm-migrations (>= 1.0.2, < 2.0)
      dm-rails (>= 1.0.2, < 2.0)
      dm-serializer (>= 1.0.2, < 2.0)
      dm-timestamps (>= 1.0.2, < 2.0)
    dm-do-adapter (1.2.0)
      data_objects (~> 0.10.6)
      dm-core (~> 1.2.0)
    dm-migrations (1.2.0)
      dm-core (~> 1.2.0)
    dm-observer (1.2.0)
      dm-core (~> 1.2.0)
    dm-postgres-adapter (1.2.0)
      dm-do-adapter (~> 1.2.0)
      do_postgres (~> 0.10.6)
    dm-rails (1.2.1)
      actionpack (~> 3.0)
      dm-active_model (~> 1.2.0)
      dm-core (~> 1.2.0)
      railties (~> 3.0)
    dm-serializer (1.2.1)
      dm-core (~> 1.2.0)
      fastercsv (~> 1.5.4)
      json (~> 1.6.1)
      json_pure (~> 1.6.1)
      multi_json (~> 1.0.3)
    dm-sqlite-adapter (1.2.0)
      dm-do-adapter (~> 1.2.0)
      do_sqlite3 (~> 0.10.6)
    dm-timestamps (1.2.0)
      dm-core (~> 1.2.0)
    dm-transactions (1.2.0)
      dm-core (~> 1.2.0)
    dm-types (1.2.1)
      bcrypt-ruby (~> 3.0.0)
      dm-core (~> 1.2.0)
      fastercsv (~> 1.5.4)
      json (~> 1.6.1)
      multi_json (~> 1.0.3)
      stringex (~> 1.3.0)
      uuidtools (~> 2.1.2)
    dm-validations (1.2.0)
      dm-core (~> 1.2.0)
    do_postgres (0.10.8)
      data_objects (= 0.10.8)
    do_sqlite3 (0.10.8)
      data_objects (= 0.10.8)
    em-websocket (0.3.6)
      addressable (>= 2.1.1)
      eventmachine (>= 0.12.9)
    erubis (2.7.0)
    eventmachine (0.12.10)
    excon (0.13.4)
    execjs (1.4.0)
      multi_json (~> 1.0)
    factory_girl (3.3.0)
      activesupport (>= 3.0.0)
    factory_girl_generator (0.0.3)
    faraday (0.8.1)
      multipart-post (~> 1.1)
    fastercsv (1.5.5)
    ffaker (1.14.0)
    ffi (1.0.11)
    friendly_id (4.0.6)
    gherkin (2.10.0)
      json (>= 1.4.6)
    growl (1.0.3)
    guard (1.0.3)
      ffi (>= 0.5.0)
      thor (>= 0.14.6)
    guard-livereload (0.4.2)
      em-websocket (>= 0.2.0)
      guard (>= 0.10.0)
      multi_json (~> 1.0)
    guard-rspec (0.7.3)
      guard (>= 0.10.0)
    haml (3.1.6)
    haml-rails (0.3.4)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      haml (~> 3.0)
      railties (~> 3.0)
    hashie (1.2.0)
    heroku (2.26.2)
      heroku-api (~> 0.2.1)
      launchy (>= 0.3.2)
      netrc (~> 0.7.2)
      rest-client (~> 1.6.1)
      rubyzip
    heroku-api (0.2.1)
      excon (~> 0.13.3)
    hike (1.2.1)
    hominid (3.0.4)
    httpauth (0.1)
    i18n (0.6.0)
    journey (1.0.3)
    jquery-rails (2.0.2)
      railties (>= 3.2.0, < 5.0)
      thor (~> 0.14)
    json (1.6.7)
    json_pure (1.6.7)
    kgio (2.7.4)
    koala (1.1.0)
      multi_json (~> 1.0)
      multipart-post (~> 1.0)
    launchy (2.1.0)
      addressable (~> 2.2.6)
    libwebsocket (0.1.3)
      addressable
    mail (2.4.4)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.18)
    multi_json (1.0.4)
    multipart-post (1.1.5)
    netrc (0.7.2)
    newrelic_rpm (3.3.4.1)
    nokogiri (1.5.2)
    oauth2 (0.6.0)
      faraday (~> 0.7)
      httpauth (~> 0.1)
      multi_json (~> 1.0)
    omniauth (1.1.0)
      hashie (~> 1.2)
      rack
    omniauth-facebook (1.3.0)
      omniauth-oauth2 (~> 1.0.2)
    omniauth-oauth2 (1.0.2)
      oauth2 (~> 0.6.0)
      omniauth (~> 1.0)
    orm_adapter (0.0.7)
    pg (0.13.2)
    polyglot (0.3.3)
    rack (1.4.1)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.1)
      rack (>= 1.0)
    railties (3.2.3)
      actionpack (= 3.2.3)
      activesupport (= 3.2.3)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.6)
    raindrops (0.9.0)
    rake (0.9.2.2)
    rdoc (3.12)
      json (~> 1.4)
    responders (0.9.1)
      railties (~> 3.1)
    rest-client (1.6.7)
      mime-types (>= 1.16)
    rspec (2.10.0)
      rspec-core (~> 2.10.0)
      rspec-expectations (~> 2.10.0)
      rspec-mocks (~> 2.10.0)
    rspec-core (2.10.1)
    rspec-expectations (2.10.0)
      diff-lcs (~> 1.1.3)
    rspec-mocks (2.10.1)
    rspec-rails (2.10.1)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec (~> 2.10.0)
    rubyzip (0.9.8)
    sass (3.1.19)
    sass-rails (3.2.5)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    selenium-webdriver (2.22.0)
      childprocess (>= 0.2.5)
      ffi (~> 1.0)
      libwebsocket (~> 0.1.3)
      multi_json (~> 1.0)
      rubyzip
    sequel (3.20.0)
    shoulda-matchers (1.1.0)
      activesupport (>= 3.0.0)
    simplecov (0.6.4)
      multi_json (~> 1.0)
      simplecov-html (~> 0.5.3)
    simplecov-html (0.5.3)
    sinatra (1.0)
      rack (>= 1.0)
    sprockets (2.1.3)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    stringex (1.3.3)
    taps (0.3.24)
      rack (>= 1.0.1)
      rest-client (>= 1.4.0, < 1.7.0)
      sequel (~> 3.20.0)
      sinatra (~> 1.0.0)
    thor (0.14.6)
    tilt (1.3.3)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    turn (0.9.5)
      ansi
    tzinfo (0.3.33)
    uglifier (1.2.4)
      execjs (>= 0.3.0)
      multi_json (>= 1.0.2)
    unicorn (4.3.1)
      kgio (~> 2.6)
      rack
      raindrops (~> 0.7)
    uuidtools (2.1.2)
    warden (1.1.1)
      rack (>= 1.0)
    xml-simple (1.1.1)
    xpath (0.1.4)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  actionmailer (~> 3.2.3)
  actionpack (~> 3.2.3)
  activeresource (~> 3.2.3)
  activesupport (~> 3.2.3)
  aws-s3
  capybara
  coffee-rails (~> 3.1)
  cucumber-rails
  dalli
  data_mapper
  dm-aggregates
  dm-constraints
  dm-core
  dm-devise (~> 2.1.0)
  dm-migrations
  dm-observer
  dm-paperclip!
  dm-postgres-adapter
  dm-rails (~> 1.2.1)
  dm-serializer
  dm-sqlite-adapter
  dm-timestamps
  dm-transactions
  dm-types
  dm-validations
  execjs
  factory_girl
  factory_girl_generator
  ffaker
  friendly_id (~> 4.0)
  growl
  guard-livereload
  guard-rspec
  haml-rails
  heroku
  hominid (~> 3.0)
  jquery-rails
  koala
  launchy
  newrelic_rpm
  omniauth-facebook
  pg
  railties (~> 3.2.3)
  responders
  rspec-rails
  sass-rails (~> 3.1)
  shoulda-matchers
  simplecov
  taps
  turn
  tzinfo (~> 0.3.32)
  uglifier (>= 1.0.3)
  unicorn

extlib messes with Kernel.exec - just remove it?

For some reason, Kernel.exec breaks when Array#to_hash is defined, if it's used in this form: Kernel.exec ['/bin/ls', '/bin/ls'], '-al'

extlib defines Array@to_hash, and selenium-webdriver uses Kernel.exec in this form, and therefore things that use selenium-webdriver (i.e. capybara) can't be used in projects that include extlib.

I don't even see it being used, unless I'm mistaken. It looks (from git blame) like it was added for a single instance of using String#camel_case, but that's no longer in the codebase, so I wonder if it could just be removed without consequences.

thumbnail.rb outdated

The thumbnail.rb file is very different than the current paperclip thumbnail.rb. It does not support convert_options properly.

Current paperclip convert_options runs the entire string through imagemagick instead of using the styles properties.

dm-paperclip convert_options runs the convert options after the cropping and sizing commands generated from the styles hash, which doesn't allow for you to customize the cropping.

Most importantly, the convert options are incompatible between the 2 gems. Hope you can take a look.

Compatiblity w/ Datamapper 1.0.2

Is dm-paper supposed to work w/ the latest Datamapper? (1.0.2). When I try to use it I get an error stating it depends on dm-core (~> 0.10.2)

Validations don't seem to work.

Using this on Sinatra/Monk application.

Uploading works beautifully but validations throw an undefined method error even if i've included DataMapper::Validate and Paperclip::Resource in my class and dm-validations is required before dm-paperclip in my init.rb.

Any suggestions?

Non-english characters in file names are stripped

Non english or accented characters in file names are replaced with underscore; for example; ça-über.xls is not allowed. This maybe a feature but maybe an option can be useful to switch to allowing international letter.. Kind regards

https://github.com/krobertson/dm-paperclip/blob/master/lib/dm-paperclip/attachment.rb
LINE 108:
instance_write(:file_name, uploaded_file['filename'].strip.gsub(/[^\w\d.-]+/, '_'))

This one works fine LINE 108
instance_write(:file_name, uploaded_file['filename'].strip.gsub(/[^\p{Word}\d.-]+/, '_'))

#url appends datetimes to attachment url

I f i call mymodel.url, i get something like images/1/thumb/wtf.jpg?45346262346&346346346

I'd like to make this configurable, because i like clean URIs and it does not make any sense as i can see anyway, except for broken browsers.

Problem with upload on Sinatra

I've run into a problem while trying to upload a file on Sinatra. Paperclip is trying to use "/public" instead of "[Application root]/public"

Although I've set the application root explicitely with

Paperclip.configure do |config|
config.root = '/my/path/to/app'
end

it didn't change anything. Paperclip still wants to write to "/public" instead of '/my/path/to/app/public'.

Maybe I've missed something. Any help would be appreciated.

Greetings

Michael Kastner

Dependecy on extlib kills routing in rails3

Still busy testing, not even done an upload yet, but adding this to a rails3 setup kills the routing. For example for an url: pages/2 rails expects a controller named PagesesController. Commenting out require 'extlib' in paperclib solves this, but might give some other trouble :)

undefined method 'read' for DataMapper::Mash

Not sure if this is exactly a paperclip issue, but using code that was working to upload to local filesystem, i just moved to use S3 and can't seem to get anything working. Here's the error i get

 NoMethodError - undefined method `read' for #<DataMapper::Mash:0x000001031e7c48>:
/Users/jon/.rvm/gems/ruby-1.9.2-p290@romey/bundler/gems/dm-paperclip-d92cc6cd0ac5/lib/dm-paperclip/attachment.rb:250:in `generate_fingerprint'
/Users/jon/.rvm/gems/ruby-1.9.2-p290@romey/bundler/gems/dm-paperclip-d92cc6cd0ac5/lib/dm-paperclip/attachment.rb:117:in `assign'
/Users/jon/.rvm/gems/ruby-1.9.2-p290@romey/bundler/gems/dm-paperclip-d92cc6cd0ac5/lib/dm-paperclip.rb:334:in `block in has_attached_file'

This is pulling from your latest (the gem file refers directly to the git repo).

The mash that's fed in there is constructed from the file upload form like so

  mash = DataMapper::Mash.new
  mash['tempfile'] = file_hash[:tempfile]
  mash['filename'] = file_hash[:filename]
  mash['content_type'] = file_hash[:type]
  mash['size'] = file_hash[:tempfile].size

where the file_hash is the params[:file] from the upload form.

Any ideas on what might be going on here?

Other specs: Sinatra, ruby 1.9.2, datamapper 1.2.0

Cheers
Jon

dm-paperclip 2.3.0 with Merb 1.1 and Bundler 0.9.16

$ gem env
RubyGems Environment:

  • RUBYGEMS VERSION: 1.3.6
  • RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10]
  • INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8
  • RUBY EXECUTABLE: /opt/local/bin/ruby
  • EXECUTABLE DIRECTORY: /opt/local/bin
  • RUBYGEMS PLATFORMS:
    • ruby
    • x86-darwin-10
  • GEM PATHS:
    • /opt/local/lib/ruby/gems/1.8
    • /Users/x/.gem/ruby/1.8
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :benchmark => false
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:

$ bundle install
...
Using dm-paperclip (2.3.0) from system gems
...

$ bundle show dm-paperclip
/opt/local/lib/ruby/gems/1.8/gems/dm-paperclip-2.3.0

$ bundle check
The Gemfile's dependencies are satisfied

However, I'm getting a standardError via bundler everytime the gem list is refreshed on page refresh:

/opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.16/lib/bundler/resolver.rb:163:in `resolve': Could not find gem 'dm-paperclip (>= 2.3, runtime)' in the gems available on this machine. (Bundler::GemNotFound)

This doesn't happen with other gems installed via bundler.

I also ran rake local to dm-paperclip and get the following

$ rake
(in /usr/local/lib/ruby/gems/1.8/gems/dm-paperclip-2.3.0)
/opt/local/bin/ruby -I"lib:dm-paperclip" "/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/attachment_test.rb" "test/geometry_test.rb" "test/integration_test.rb" "test/iostream_test.rb" "test/paperclip_test.rb" "test/storage_test.rb" "test/thumbnail_test.rb"
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require': no such file to load -- shoulda (LoadError) from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from ./test/helper.rb:3
from ./test/attachment_test.rb:1:in require' from ./test/attachment_test.rb:1 from /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:inload'
from /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
from /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
rake aborted!
Command failed with status (1): [/opt/local/bin/ruby -I"lib:dm-paperclip" "...]

Using validations on 2.4.1

Validations on Ruby 1.8.7, dm-paperclip 2.4.1, 2.5.0

All works fine until we add paperclip validations.
When running we get:

undefined method `validates_attachment_size' for User:Class - (NoMethodError) 

We have it initialized:

config.use_dm_validations = true 

The model is:

class User
  include DataMapper::Resource
  include Paperclip::Resource

  # ...
  has_attached_file :avatar, 
        :styles => { :medium => "300x300>", :thumb => "100x100>" },
            :path => "#{EFILESDIR}/images/:attachment/:id/:style/:filename",
            :url  => "/images/:attachment/:id/:style/:filename"

  validates_attachment_size :avatar, :in => 1..5120, :message => "Image too large"
  validates_attachment_content_type :avatar, :content_type => ["image/png","image/jpeg"], :message => "Imagem formats accepted .PNG, .JPEG"

  # ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.