Rails:载波未初始化常量误差
我有 Rails 3
Carrierwave 0.5.4
//app/uploaders/fasta_uploader.rb
class FastaUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
'public/data/01_fasta'
end
end
//migration
class AddFileUpToCvits < ActiveRecord::Migration
def self.up
add_column :cvits, :fasta, :string
end
def self.down
remove_column :cvits, :fasta
end
end
//app/models/cvit.rb
class Cvit < ActiveRecord::Base
attr_accessible :fasta
mount_uploader :fasta, FastaUploader
end
//form
<%= 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
有什么建议吗???
I have Rails 3
Carrierwave 0.5.4
//app/uploaders/fasta_uploader.rb
class FastaUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
'public/data/01_fasta'
end
end
//migration
class AddFileUpToCvits < ActiveRecord::Migration
def self.up
add_column :cvits, :fasta, :string
end
def self.down
remove_column :cvits, :fasta
end
end
//app/models/cvit.rb
class Cvit < ActiveRecord::Base
attr_accessible :fasta
mount_uploader :fasta, FastaUploader
end
//form
<%= 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 %>
I get this error: uninitialized constant Cvit::FastaUploader
Any suggestions???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对服务器进行简单的重置即可解决问题 -_- 你生活,你学习。
A simple reset of the server fixed the problem -_- You live and you learn.
重新启动服务器对我来说不起作用。我重新启动了我的 Mac,问题就解决了。
Restarting the server doesn't work for me. I restarted my mac and it fixed the issue.
看起来我的问题是在上传器本身初始化之前存在一些初始化代码。
我引用了我的一个模型,该模型在位于 config/initializers 的初始化文件内引用了上传器。
Looks like my problem was with some initialization code before the uploader could be initialized itself.
I had a reference to one of my models that had a reference to the uploader inside of an initialization file located at config/initializers.