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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:44:01+00:00 2026-06-01T22:44:01+00:00

I’m using Simple Form. I have a form for creating new items, and a

  • 0

I’m using Simple Form. I have a form for creating new items, and a form for editing existing ones. I also have two file fields for every item. Thing that bugs me is that file fields are displayed fine when creating new item, but then they are not generated at all when editing an existing item.

I had this perfectly working in Rails 3.0, now doesn’t work on Rails 3.2.1.

The form:

<%= simple_form_for @item, :html => { :multipart => true } do |f| %>
    <%= f.input :title, :input_html => { :maxlength => 35 } %>
    <%= f.input :description, :input_html => { :maxlength => 450 } %>
    <%= f.input :secure_details, :placeholder => "Serial numbers and other stuff that will remain private", :input_html => { :maxlength => 450 } %>
    <%= f.association :bookmark, :collection => current_user.bookmarks(:order => :position), :include_blank => false %>
    <%= f.input :warranty_until, :as => :string, :input_html => { :id =>'datepicker2' } %>
    <div class="image_attachment">
        <div class="attachment_text">
            Update item photo<br />
            <small>(will replace old one)</small>
        </div>
        <div class="attachment_button">
        <% f.fields_for :assets do |asset| %>
            <%= asset.file_field :photo %>
        <% end %>
        </div>
    </div>
    <div class="image_attachment">
        <div class="attachment_text">
            Update receipt<br />
            <small>(will replace old one)</small>
        </div>
        <div class="attachment_button">
        <% f.fields_for :receipts do |receipt| %>
            <%= receipt.file_field :photo %>
        <% end %>
        </div>
    </div>
    <%= f.input :public, :label => "My friends can see this item", :input_html => { :class => "right" } %>
    <%= f.input :giveaway, :label => "Mark as giveaway", :input_html => { :class => "right" } %>
    <div class="margin_r margin_t">
        <%= f.button :submit, :class => 'small_button white right' %>
    </div>

<% end %>

Basically this part of code doesn’t work:

<div class="attachment_button">
        <% f.fields_for :assets do |asset| %>
            <%= asset.file_field :photo %>
        <% end %>
</div>

The generated HTML is just empty div.

The very same code works when creating a new item, but doesn’t work when editing existing one.

Both Assets and Receipts are using Paperclip for storing images. Here is a code for Asset class:

class Asset < ActiveRecord::Base
    belongs_to :item

    has_attached_file :photo, 
        :styles => {
            :thumb => "80x80#",  
            :small => "150x150>" }
    validates_attachment_size :photo, :less_than => 550.kilobytes
    validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png']

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-06-01T22:44:02+00:00Added an answer on June 1, 2026 at 10:44 pm

    Maybe you forgot add this line of code in your Item model:

    accepts_nested_attributes_for :receipts, :allow_destroy => true
    accepts_nested_attributes_for :assets, :allow_destroy => true
    

    And add ‘=’:

    <%= f.fields_for :assets do |asset| %>
        <%= asset.file_field :photo %>
    <% end %>
    
    <%= f.fields_for :receipts do |receipt| %>
        <%= receipt.file_field :photo %>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.