我有Rails 3
Carrierwave 0.5.4
//应用程序/上传/ fasta_uploader.rb
class FastaUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
'public/data/01_fasta'
end
end
//迁移
class AddFileUpToCvits < ActiveRecord::Migration
def self.up
add_column :cvits, :fasta, :string
end
def self.down
remove_column :cvits, :fasta
end
end
//应用/模型/ cvit.rb
class Cvit < ActiveRecord::Base
attr_accessible :fasta
mount_uploader :fasta, FastaUploader
end
//形式
<%= form_for(@cvit, :html => {:multipart => true, :onsubmit => "return ray.ajax()" }) do |f| %>
...
...
<%= f.file_field :fasta %><br></br>
<div class="actions">
<%= f.submit "Submit"%>
</div>
<% end %>
我收到此错误:未初始化的常量Cvit :: FastaUploader
任何建议???
答案 0 :(得分:60)
简单的服务器重置修复了问题-_-你活着并且你学习。