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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:26:12+00:00 2026-05-30T18:26:12+00:00

I followed the tutorial http://railscasts.com/episodes/253-carrierwave-file-uploads?view=asciicast and I’ve got my nested form setup with the

  • 0

I followed the tutorial http://railscasts.com/episodes/253-carrierwave-file-uploads?view=asciicast and I’ve got my nested form setup with the attached inside a nested form below. Everything works fine but the image isn’t being uploaded / storing the filename in the db.

<%= simple_nested_form_for(@order) do |f| %>
  <%= f.error_notification %>

  <div class="inputs">
        <label> <%= link_to 'New Customer', new_customer_path %> <small>or</small></label><div class="clear"></div>
        <%= f.association :customer, :label =>'Existing Customer', :include_blank => false %>
        <%= f.input :due_date, :as => :date, :start_year => Date.today.year, :start_day => Date.today.day, :stary_month => Date.today.month, :order => [:month, :day, :year], :input_html => { :class => 'date' }  %>
        <%= f.input :sales_tax, :input_html => { :class => 'text', :value => current_user.sales_tax, :onChange=>"itemcalculate()", :id => 'invoice-salestax' }, :hint => '%'  %>
        <%= f.input :discount, :input_html => { :class => 'text', :onChange=>"itemcalculate()", :id => 'invoice-discount' }, :placeholder => '$30', :label => 'Discount'  %>

            <%= f.fields_for :lineitems do |item| %>
                <div id='size'>
                <label style="margin-top:0 !important;">Details</label>
                <%= item.input :product_name, :input_html => { :class => 'text' }, :label => false, :wrapper_html => { :class => 'detail-wrapper' }, :input_html => { :class => 'details'}, :hint => 'Product Name', :placeholder => 'Gildan 2000'  %>
                <%= item.input :color, :input_html => { :class => 'text' }, :label => false, :wrapper_html => { :class => 'detail-wrapper' }, :input_html => { :class => 'details'}, :hint => 'Product Color', :placeholder => 'Blue'  %>
                <%= item.input :price_per, :input_html => { :class => 'text details', :onChange=>"itemcalculate()", :id => 'invoice-priceper' }, :label => false, :wrapper_html => { :class => 'detail-wrapper' }, :hint => 'Price per', :placeholder => "4.50", :required => true  %>
                <%= item.input :extra_fee, :input_html => { :class => 'text details', :onChange=>"itemcalculate()", :id => 'invoice-extrafee' }, :label => false, :wrapper_html => { :class => 'detail-wrapper', :value => '0' }, :hint => 'Extra fee', :required => true  %>
            <div class='clear'></div>
                <label>Sizes</label>                
                <%= item.input :xxs, :input_html => { :class => 'sizes', :value => '0', :onChange=>"itemcalculate()", :id => 'invoice-xxs' },  :hint=> 'xxs', :label => false, :wrapper_html => { :class => 'size-wrapper' } %>
                <%= item.input :xs, :input_html => { :class => 'sizes', :value => '0', :onChange=>"itemcalculate()", :id => 'invoice-xs' },  :hint=> 'xs', :label => false, :wrapper_html => { :class => 'size-wrapper' } %>
                <%= item.input :s, :input_html => { :class => 'sizes', :value => '0', :onChange=>"itemcalculate()", :id => 'invoice-s' },  :hint=> 's' , :label => false, :wrapper_html => { :class => 'size-wrapper' }%>
                <%= item.input :m, :input_html => { :class => 'sizes', :value => '0', :onChange=>"itemcalculate()", :id => 'invoice-m' },  :hint=> 'm', :label => false, :wrapper_html => { :class => 'size-wrapper' } %>
                <%= item.input :l, :input_html => { :class => 'sizes', :value => '0', :onChange=>"itemcalculate()", :id => 'invoice-l' },  :hint=> 'l', :label => false, :wrapper_html => { :class => 'size-wrapper' } %>
                <%= item.input :xl, :input_html => { :class => 'sizes', :value => '0', :onChange=>"itemcalculate()", :id => 'invoice-xl' },  :hint=> 'xl', :label => false, :wrapper_html => { :class => 'size-wrapper' } %>
                <%= item.input :xxl, :input_html => { :class => 'sizes', :value => '0', :onChange=>"itemcalculate()", :id => 'invoice-xxl' },  :hint=> 'xxl', :label => false, :wrapper_html => { :class => 'size-wrapper' } %>

                <label>Extra Notes</label>
                <%= item.text_area :extra_notes %>

                <!-- start image upload -->
                    <%= item.fields_for :images, :html => {:multipart => true} do |image| %>
                    <%= f.file_field :image %>
                    <%= image.link_to_remove "Remove Image", :id => 'remove-image' %>
                    <% end %>
                    <%= item.link_to_add "<img src='/images/icon-camera.png' id='camera-icon'/> Add an image".html_safe, :images, :id=> 'add-image'  %>
                <!-- end image upload -->

                <div class='clear'></div>
                <%= item.link_to_remove "Remove Item" %>

                </div>
            <% end %>

            <p id='add-new-item'><%= f.link_to_add "+ Add an Item", :lineitems  %></p>
            </div>
            <%= f.hidden_field :user_id, :value => current_user.id %>
  <div class="actions">
    <%= f.button :submit %>
  </div>
<% end %>

I’m getting the error WARNING: Can't mass-assign protected attributes: image
WARNING: Can't mass-assign protected attributes: images_attributes

My Image model looks like this:

class Image < ActiveRecord::Base
  attr_accessible :lineitem_id, :image
  belongs_to :lineitem, :polymorphic => true
  mount_uploader :image, ImageUploader

end
# == Schema Information
#
# Table name: images
#
#  id          :integer         not null, primary key
#  lineitem_id :integer
#  image       :string(255)
#  created_at  :datetime
#  updated_at  :datetime
#

Any idea what’s wrong?

  • 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-30T18:26:13+00:00Added an answer on May 30, 2026 at 6:26 pm

    in your image upload section, i think you want

    <%= image.file_field :image %>
    

    instead of

    <%= f.file_field :image %>
    

    sounds/looks like you’re trying to tack the image file field onto the orders form when it should be part of the nested form you created for the image.

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

Sidebar

Related Questions

I've just followed the Railscast tutorial: http://railscasts.com/episodes/262-trees-with-ancestry Is it possible to paginate results from
I've followed the tutorial available at http://railscasts.com/episodes/221-subdomains-in-rails-3 . It allows you to pass a
I recently implemented Authlogic to my project for authentication. I followed http://railscasts.com/episodes/160-authlogic and had
I followed this tutorial : http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/ and I got the alert 'Text messaging is
I am using iOS SDK 4.2 and followed this tutorial: http://mobileorchard.com/hello-there-a-corelocation-tutorial/ , and got
I have followed this tutorial http://blogs.wrox.com/article/creating-a-simple-ipad-application-table-view/ (creating a uitableview and populating it). I want
I've followed this tutorial: http://anandhansubbiah.com/blog/writing-your-first-android-application/ , but no matter what I do, and what
I followed this tutorial: http://codeigniter.com/wiki/Internationalization_and_the_Template_Parser_Class/ The controller that loads the language is this one:
I have followed this tutorial: http://www.phpjabbers.com/how-to-make-a-php-calendar-php26-6.html#comments to make a very basic calendar. My aim
first time trying XNA Framework in C#.. followed this tutorial: http://www.uxmagic.com/blog/post/2010/08/17/e2809cHello-Worlde2809d-for-XNA-Game-Studio-40.aspx Everything's ok until

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.