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

  • SEARCH
  • Home
  • 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 4016400
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:44:07+00:00 2026-05-20T09:44:07+00:00

Just started using carrierwave with Rails and things have been going smoothly with one

  • 0

Just started using carrierwave with Rails and things have been going smoothly with one minor exception. I created a “ImageUploader” class which looks so:

class ImageUploader < CarrierWave::Uploader::Base

include CarrierWave::RMagick
  def extension_white_list
    %w(jpg jpeg gif png)
  end
end

and a controller action which looks like so:

def update
  @user = current_user
  if params[:user].nil? || params[:user][:image].nil?
    redirect_to user_path(@user)
  else
    if @user.update_attribute(:image, params[:user][:image])
      flash[:success] = "Profile updated successfully!"
      redirect_to user_path(@user)
    else
      flash[:error] = "Changes could not be saved."
      render :action => 'edit'
    end      
  end
end

In this case I mounted the uploader in my User.rb like so:

mount_uploader :image, ImageUploader

Problem is, according to the Carrierwave README, uploaded files with extensions not in the extensions_white_list should make the record invalid. In my case I have purposely been testing the app by uploading files with various extensions not on the white list and no error is being raised. In fact, @user.update_attribute seems to pass and I am usually redirected to user_path(@user) with a flash[:success] message. The image itself is not actually changed, but I would like to be able to catch the error and redirect to the ‘edit’ page in case of an incorrect extension type. Any ideas on what I am doing wrong here?

  • 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-20T09:44:08+00:00Added an answer on May 20, 2026 at 9:44 am

    For anyone interested I sort of found a workaround for this myself. Not the most elegant solution, but in any case here’s what worked for me:

    @user.image = params[:user][:image]
    if @user.image_integrity_error
        flash[:error] = "Changes could not be saved."
        @user.errors.add(:upload, @user.image_integrity_error)
        render 'edit'
    else
        @user.update_attribute(:image, @user.image)
        flash[:success] = "Profile updated successfully!"
        redirect_to user_path(@user)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started using vc++ 2008. I just want to see one message
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I just started using SVN, and I have a cache directory that I don't
Just started using CodeIgniter, loving it. Having enabled the database to be one of
just started using log4j in one of my home-projects and I was just about
I have just started using services in Android and I have a made a
just started using JPA today, so i'm preety new to it. How would one
I just started using Resharper. One of its features is that it suggests changes
I just started using EF, and heres what I have: dataEntity = new ThisProject.Data.Entities();

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.