thoughtbot/paperclip — Issue #774: id not being generated on save, /:id/ paths are null even though record is created in DB
Author: mattsly
Created: 2012-03-08 05:18:41+00:00
State: open

I'm working on moving my project to 2.7 (having used paperclip 2.3 w/ joy for over a year...) and am encountering an issue w/ IDs not
being accessible on initial save, and the S3 path is wrong and the file is put in the wrong spot.

Here's an rails console history illustrating what's going on (name of my :has_attached_file model is called Attachment ... I know...confusing...)

```ruby
irb(main):054:0> a = Attachment.new
=> #

irb(main):055:0> a.file = open("/tmp/test.jpg")
=> #

irb(main):056:0> a.save
=> true

irb(main):057:0> a.file.url
=> "http://s3.amazonaws.com/bucketname/dir//original/test.jpg?1331182470"
```

* the file is indeed uploaded to this location, but notice the // where the id is supposed to be, according to my configuration, which includes:*
:path => "/letters/:id/:style/:filename"

and indeed - the model doesn't appear to have an ID.

```ruby
irb(main):060:0> a.id
=> nil
```

...however, when I see what was inserted, the data looks fine:

```ruby
irb(main):067:0> a = Attachment.last
=> #

irb(main):065:0> Attachment.last.file.url
=> "http://s3.amazonaws.com/futureme-dev/dir/10093/original/test.jpg?1331182470"
```

...but the major issue is that the expected and correct url is a 404, since the initial file upload didn't have the proper ID value and was placed in the wrong location.

my system: Rails 3.0.11, Paperclip 2.7, aws-sdk 1.3.4, ruby 1.9.3p0