title: rails 3: carrierwave default_url bug, not using the right version
body: <p>Hi I'm trying to get different versions of the default image to work for my avatar_uploader. I've had this working before with 2 version but not that I've added 4 versions there seems to be a bug that I can't figure out. When I reference my :small version's default image it displays the :large version's default. I've removed the large_avatar_defaualt.png file from my public/images/fallback folder and confirmed the request is indeed looking for large_avatar_default.png. As you can see by my code below I'm point to the correct avatar version, any idea why this would be happening? </p>
  
  <pre><code>Started GET "/users/example123/following" for 127.0.0.1 at 2011-10-29 13:16:31 -0700
    Processing by UsersController#following as JS
    Parameters: {"id"=&gt;"example123"}
    User Load (62.3ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
    User Load (3.5ms)  SELECT "users".* FROM "users" WHERE "users"."cached_slug" = 'example123' LIMIT 1
    User Load (2.1ms)  SELECT "users".* FROM "users" INNER JOIN "relationships" ON "users".id = "relationships".followed_id WHERE (("relationships".follower_id = 1)) LIMIT 30 OFFSET 0
  Rendered users/_user.html.erb (3.5ms)
  Rendered users/_users.html.erb (5.5ms)
  Rendered users/following.js.erb (7.5ms)
  Completed 200 OK in 312ms (Views: 25.2ms | ActiveRecord: 69.2ms)
  
  
  Started GET "/images/fallback/large_avatar_default.png" for 127.0.0.1 at 2011-10-29 13:16:31 -0700
  
  ActionController::RoutingError (No route matches "/images/fallback/large_avatar_default.png"):
  
  
  Rendered /Users/iHal/.rvm/gems/ruby-1.9.2-p290@rails3/gems/actionpack-3.0.7/lib/action_dispatch/mid
  
  dleware/templates/rescues/routing_error.erb within rescues/layout (1.1ms)
  </code></pre>
  
  <p>views</p>
  
  <p>users.html.erb</p>
  
  <pre><code>&lt;% if users.empty? %&gt;
  &lt;%= @empty_msg %&gt;
  &lt;% else %&gt;
  &lt;%= @title %&gt;
  &lt;% users.each do |user| %&gt;
  &lt;%= render 'user', :user =&gt; user %&gt;
  &lt;% end%&gt;
  &lt;% end%&gt;
  </code></pre>
  
  <p>user.html.erb</p>
  
  <pre><code>&lt;div&gt;
    &lt;%= small_avatar_for user %&gt;
    &lt;%= link_to user.name, user %&gt;
    &lt;%= link_to user.username, user %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>users_helper.rb</p>
  
  <pre><code>module UsersHelper
  
    def tiny_avatar_for(user)
       image_tag(user.avatar_url(:tiny).to_s, :alt =&gt; "avatar", :class =&gt; "round-3")
     end
  
    def small_avatar_for(user)
      image_tag(user.avatar_url(:small).to_s, :alt =&gt; "avatar", :class =&gt; "round-3")
    end
  
     def medium_avatar_for(user)
         image_tag(user.avatar_url(:medium).to_s, :alt =&gt; "avatar", :id =&gt; "align-middle", :class =&gt; "round-3")
       end
  
    def large_avatar_for(user)
       image_tag(user.avatar_url(:large).to_s, :alt =&gt; "avatar", :class =&gt; "round-10", :id =&gt; "center-big-avatar")
     end
  end
  </code></pre>
  
  <p>class AvatarUploader &lt; CarrierWave::Uploader::Base</p>
  
  <pre><code> # Include RMagick or ImageScience support:
    include CarrierWave::MiniMagick
    # include CarrierWave::ImageScience
  
    # Choose what kind of storage to use for this uploader:
    #storage :file
    # storage :s3
  
    # Override the directory where uploaded files will be stored.
    # 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
  
    # Provide a default URL as a default if there hasn't been a file uploaded:
    def default_url
     "/images/fallback/" + [tiny, "tiny_avatar_default.png"].compact.join('_')
     "/images/fallback/" + [small, "small_avatar_default.png"].compact.join('_')
     "/images/fallback/" + [medium, "medium_avatar_default.png"].compact.join('_')
     "/images/fallback/" + [large, "large_avatar_default.png"].compact.join('_')
    end
  
    # Process files as they are uploaded:
    # process :scale =&gt; [200, 300]
    process :resize_to_fit =&gt; [600, 600]
  
    # def scale(width, height)
    #   # do something
    # end
  
    # Create different versions of your uploaded files:
  
    version :large do
      process :resize_to_fill =&gt; [165, 165]
    end
    version :medium do
      process :resize_to_fill =&gt; [75, 75]
    end
    version :small do
      process :resize_to_fill =&gt; [45, 45]
    end
    version :tiny do
      process :resize_to_fill =&gt; [20, 20]
    end
    # Add a white list of extensions which are allowed to be uploaded.
    # For images you might use something like this:
    def extension_white_list
      %w(jpg jpeg gif png)
    end
  
    # Override the filename of the uploaded files:
    def filename
      "avatar.#{File.extname(original_filename).downcase}" if original_filename
    end
    def filename
      if Rails.env.production?
        name_s3
      else
        name_file
      end
    end
  
    def name_s3
      # S3 storage class is Carrierwave::Storage::S3::File
      "avatar.#{File.extname(original_filename).downcase}" if original_filename     
    end
  
    def name_file
      # :file storage class is Carrierwave::Storage::File
      "avatar.#{model.avatar.file.extension}" if original_filename
    end
  end
  </code></pre>