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 8359487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:09:31+00:00 2026-06-09T11:09:31+00:00

There is already a similar question here Rails + CarrierWave: NoMethodError: undefined method `name'

  • 0

There is already a similar question here Rails + CarrierWave: NoMethodError: undefined method `name' for nil:NilClass but the solution there was to fix a typo.

I am already using Rails and Carrierwave in the same project with no problems. There is a simple AR model:

class Upload < ActiveRecord::Base
  attr_accessible :title, :data_file, :caption
  mount_uploader :upload, DataFileUploader

  validates :title, :data_file, :presence => true
end

In the controller thers is as usual:

def create
  @upload = Upload.new(params[:upload])

  if @upload.save
    redirect_to new_admin_upload_path, :notice => t("site.successfully_created_resource")
  else
    render :action => 'new'
  end
end

Straight forward. When submitting the form the following error occures:

ActiveRecord::StatementInvalid in Admin::UploadsController#create

NoMethodError: undefined method `name' for nil:NilClass: INSERT INTO "uploads" ("caption",    
"created_at", "data_file", "title", "updated_at") VALUES (?, ?, ?, ?, ?)

I don’t see the error and don’t understand, where name comes from. When leaving away mount_uploader :upload, DataFileUploader in the AR model, everything works fine.

What is wrong here?

Thanks a lot!

  • 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-06-09T11:09:33+00:00Added an answer on June 9, 2026 at 11:09 am

    I had exactly the same error and the solution was to connect uploader to existing field in my model. For your example the fix will be to change from

    class Upload < ActiveRecord::Base
      attr_accessible :title, :data_file, :caption
      mount_uploader :upload, DataFileUploader
    
      validates :title, :data_file, :presence => true
    end
    

    to

    class Upload < ActiveRecord::Base
      attr_accessible :title, :data_file, :caption
      mount_uploader :data_file, DataFileUploader
    
      validates :title, :data_file, :presence => true
    end
    

    if you have data_file field in Upload model and don’t have upload field (examining your db/schema.rb file will be helpful).

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

Sidebar

Related Questions

Pardon me if there's a similar question somewhere on here already, but I couldn't
There's already a question on this here. But i want to know if its
i was trying to see if there's already a similar question but couldn't find
There has already been a question posted here which is very similar. Mine is
I already asked similar question here, but I still get some errors, so I
I know there are already some similar questions here. But I do not want
There is already a similar question( link ).The thing is I don't understand what
Question is similar to this , earlier question Which Dimitre has answered already. There
There are some similar questions like this already, but none of those fixes worked
There are already several questions with a similar title, but they received either no

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.