Paperclip gem をインストールし、それを使用してモデルに :image 列を生成しました。次に、ビューを編集して写真をアップロードできるようにしました。
<%= form_for @book = Book.new, :html => { :multipart => true } do |f| %>
...
...
...
<%= f.file_field :image %>
私のモデルでは、次の行を入力しました。
has_attached_file :image, :styles => { :smal => "200x200>"}
:url => "/assets/books/:id/:style/:basename.:extension",
:path => ":rails_root/public/assets/books/:id/:style/:basename.:extension"
写真のアップロードを選択できます。アップロードすると、missing.png というエラーが表示されます。画像名はそのようではありませんが、写真がまったくアップロードされていないようです。何が間違っている可能性がありますか?編集:完全なエラー:
No route matches [GET] "/assets/books/17/small/thunderbird-logo-200x200.png"
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/usr/local/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/usr/local/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/usr/local/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
Rendered /usr/local/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (5.9ms)
Rendered /usr/local/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/routes/_route.html.erb (2.5ms)
Rendered /usr/local/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/routes/_table.html.erb (1.3ms)
Rendered /usr/local/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (27.2ms)