Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6918597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:52:48+00:00 2026-05-27T09:52:48+00:00

Hi I’m trying to get different versions of the default image to work for

  • 0

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?

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"=>"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)

views

users.html.erb

<% if users.empty? %>
<%= @empty_msg %>
<% else %>
<%= @title %>
<% users.each do |user| %>
<%= render 'user', :user => user %>
<% end%>
<% end%>

user.html.erb

<div>
  <%= small_avatar_for user %>
  <%= link_to user.name, user %>
  <%= link_to user.username, user %>
</div>

users_helper.rb

module UsersHelper

  def tiny_avatar_for(user)
     image_tag(user.avatar_url(:tiny).to_s, :alt => "avatar", :class => "round-3")
   end

  def small_avatar_for(user)
    image_tag(user.avatar_url(:small).to_s, :alt => "avatar", :class => "round-3")
  end

   def medium_avatar_for(user)
       image_tag(user.avatar_url(:medium).to_s, :alt => "avatar", :id => "align-middle", :class => "round-3")
     end

  def large_avatar_for(user)
     image_tag(user.avatar_url(:large).to_s, :alt => "avatar", :class => "round-10", :id => "center-big-avatar")
   end
end

class AvatarUploader < CarrierWave::Uploader::Base

 # 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 => [200, 300]
  process :resize_to_fit => [600, 600]

  # def scale(width, height)
  #   # do something
  # end

  # Create different versions of your uploaded files:

  version :large do
    process :resize_to_fill => [165, 165]
  end
  version :medium do
    process :resize_to_fill => [75, 75]
  end
  version :small do
    process :resize_to_fill => [45, 45]
  end
  version :tiny do
    process :resize_to_fill => [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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:52:49+00:00Added an answer on May 27, 2026 at 9:52 am

    This should do the trick!

    def default_url
      "/images/fallback/" + [version_name, "avatar_default.png"].compact.join('_')
    end
    

    version_name will pass the name of the version requested.

    Otherwise CSS is your friend!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.