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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:39:22+00:00 2026-05-19T01:39:22+00:00

Based on Railscast 196 and 197 , I’ve created a nested form for adding

  • 0

Based on Railscast 196 and 197, I’ve created a nested form for adding multiple illustrations (image attachments) to my article model. I have a form like this:

<%= form_for @article, :html => { :multipart => true } do |f| %>  
  <h2>Illustrations</h2>
  <% for illustration in @article.illustrations %>    
    <%= f.fields_for :illustrations, illustration do |builder| %>  
       <%= render :partial => "illustration_fields", 
         :locals => { :f => builder, :illustration => illustration } %>
    <% end %>
  <% end %>
  <p>  
    <%= f.submit "Submit" %>  
  </p>
<% end %>

And the _illustration_fields partial looks like this:

<div class="fields">
  <p>
    <%= f.label :illustration, "Illustration" %><br />
    <%= link_to_remove_fields "remove", f %><br />
    <%= f.file_field :illustration %>  
  </p>
</div>

If the illustration already exists, I want to display it on the page inside an image tag. I tried displaying the image inside the partial like this:

<% unless :illustration.illustration.blank? %>
   <%= image_tag(:illustration.illustration.url) %>
<% end %>

But it throws up an error:

undefined method `illustration' for :illustration:Symbol

The illustration field definitely exists in the illustration model, as I can display the image inside the main form like this:

<% unless illustration.illustration.blank? %>
  <%= image_tag(illustration.illustration.url) %>
<% end %>

It seems that Rails doesn’t understand the illustration information into the partial (or I’m not passing it correctly). What is the correct approach to going about this?

  • 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-19T01:39:22+00:00Added an answer on May 19, 2026 at 1:39 am

    Solved it. The illustration object can be accessed from inside the partial as follows. No need to pass it inside the :locals hash.

    <% unless f.object.illustration.blank? %>
      <%= image_tag(f.object.illustration.url) %>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on a simple test I ran, I don't think it's possible to put
Based on a few posts I've read concerning version control, it seems people think
Based on all my reading there should be one GC thread to invoke all
Based on their work, how do you distinguish a great SQL developer? Examples might
Based on the response to this question: Why does C++ have header files and
Based on this question it appears that the default template for CheckStyle will allow
Based on my previous question here my new concern is how do I unit
Based on this question I don't want to litter my ready stuff waiting for
Based on information in Chapter 7 of 3D Programming For Windows (Charles Petzold) ,
Based on the code I've found, it seems that the Visitor is required to

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.