23

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???

0

3 Answers 3

66

A simple reset of the server fixed the problem -_- You live and you learn.

Sign up to request clarification or add additional context in comments.

14 Comments

The server reset is necessary if you have not restarted since generating your first uploader. I believe it's because your first uploader class results in a new 'uploaders' folder being created, and it is not on the search path by default.
I made it too, and you save me any real time in solving it.
On my Mac, I had to close the terminal session and restart rails console. A simple stop and restart in the same terminal session didn't work for me.
And if you use spring with rails, make sure to spring stop as well.
got me too... doh!. Even 4 years later.
|
0

Restarting the server doesn't work for me. I restarted my mac and it fixed the issue.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.