0

我搜索了很多。我正面临这个错误 在此处输入图像描述

控制器中的创建方法是

def create @category = Category.new(params[:category])

respond_to do |format|
  if @category.save
    format.html { redirect_to @category, notice: 'Category was successfully created.' }
    format.json { render json: @category, status: :created, location: @category }
  else
    format.html { render action: "new" }
    format.json { render json: @category.errors, status: :unprocessable_entity }
  end
end
end

我的表格是

<%= form_for @category, :html => { :multipart => true } do |f| %>
<% if @category.errors.any? %>
<div id="error_explanation">
  <h2><%= pluralize(@category.errors.count, "error") %> prohibited this category from   being saved:</h2>

  <ul>
  <% @category.errors.full_messages.each do |msg| %>
    <li><%= msg %></li>
  <% end %>
  </ul>
  </div>
  <% end %>

 <div class="field">
  <%= f.label :name %><br />
  <%= f.text_field :name %>
 </div>
 <div class="field">
   <%= f.label :description %><br />
   <%= f.text_area :description%>
 </div>

 <div class="field">
    <%= f.file_field :image %>
 </div>

 <div class="actions">
    <%= f.submit %>
 </div>
 <% end %>

当我选择要上传的文件并单击提交按钮时不继续

我的上传者是

# encoding: utf-8
require 'carrierwave/processing/rmagick'
class ImageUploader < CarrierWave::Uploader::Base

#Include RMagick or MiniMagick support
include CarrierWave::RMagick

# Choose what kind of storage to use for this uploader:
storage :file

# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end

def scale(width, height)
 # do something
end

# Create different versions of your uploaded files:
  version :thumb do
  process :resize_to_fill => [80, 80]
  end

end
4

1 回答 1

0

我已经创建了新项目,以相同的方式应用所有内容及其工作,仍然不知道为什么会发生此错误,但现在我没有问题。

于 2012-05-02T06:43:15.277 回答