I am making my first steps with the Rails plugin 'paperclip' an therefor watched the RailsCast #134: http://railscasts.com/episodes/134-paperclip
Did everthing the same, except that I'm running rails 3.0.9 and installed paperclip (2.3.15) via adding it to the Gemfile.
Until 3:00 of the cast, everything works fine. But after reloading the show-page, I get the "missing" image instead of the uploaded image. Also, inside of the 'public' directory nothing new has been created.
Any hints?
Update: As requested here the relevant code:
Gemfile:
…
gem 'paperclip'
gem 'rails', '3.0.9'
…
config/routes.rb:
Foobar::Application.routes.draw do
resources :books
end
app/models/book.rb:
class Book < ActiveRecord::Base
has_attached_file :cover
attr_accessor :cover_file_name
end
app/controllers/books_controller.rb:
# nothing changed here after scaffolding
app/views/books/_form.html.erb:
<%= form_for(@book, :html => { :multipart => true}) do |f| %>
…
<div class="field">
<%= f.file_field :cover %>
</div>
app/views/books/show.html.erb:
…
<%= image_tag «book.cover.url %>
…
db/migrate/..._create_books.rb:
class CreateBooks < ActiveRecord::Migration
def self.up
create_table :books do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :books
end
end
db/migrate/..._ad_attachment_cover_to_book.rb:
class AddAttachmentCoverToBook < ActiveRecord::Migration
def self.up
add_column :books, :cover_file_name, :string
add_column :books, :cover_content_type, :string
add_column :books, :cover_file_size, :integer
add_column :books, :cover_updated_at, :datetime
end
def self.down
remove_column :books, :cover_file_name
remove_column :books, :cover_content_type
remove_column :books, :cover_file_size
remove_column :books, :cover_updated_at
end
end
I started up with "rails generate paperclip book cover" after having scaffold "book"