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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:46:25+00:00 2026-06-11T20:46:25+00:00

This is my code for rendering the partial (the @parties collection is being generated

  • 0

This is my code for rendering the partial (the @parties collection is being generated correctly, I have tested that):

        <% @parties.each do |party| %>
            <div class="item">
              <%= render 'parties/party', :object => party  %>
            </div>
        <% end %>

And this is the code in the partial:

<%= party.name %>

However, I get the following error:

undefined method `name' for nil:NilClass

I’m at my wits end, someone please help 😐

Also, this is the code for the controller to render the view containing the partial (The controller’s called default_controller):

def index
    @parties = Party.all
end

Is it of any consequence that this isn’t the parties_controller?

  • 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-11T20:46:27+00:00Added an answer on June 11, 2026 at 8:46 pm

    I’ve tried something like below and it worked

    <%= render :partial => 'party', :object => party  %>
    

    and I can access like party.name. the local variable is named after the partial name which is party here.

    Note: Im assuming that your both partials are of parties_controller. So this should work.

    Update:
    Here is what ive tried with again

    class PostsController < ApplicationController
        #... ...
        def index
            @posts = Post.all
            @comments = Comment.all #<---- Loading comments from PostsController
            #... ...
        end  
    end
    

    #views/posts/index.html.erb
    
    <% @comments.each do |comment| %>
        <%= render :partial=>"comments/comment", :object=>comment %>
    <% end %>
    

    #views/comments/_comment.html.erb
    
    <%= comment.body %>
    

    And its working 🙂

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

Sidebar

Related Questions

I have jquery code that is being reused by a repeatable partial view on
I have a collection of partials being rendered using a layout for each element
I am rendering this line of code in a <pre> tag to display as
This code is the core of a much larger script that works great in
This code is not pretty, but I want to print out the last generated
I need your opinion about this code below. I have a list of messages:
I have a HTML table with a column per row with this html code
I have a p:fileUpload which works fine. But I need a partial page rendering
I'm stuck trying to solve this. I'm plotting some information that I have in
i'm seeing a really strange issue with asp.net rendering. i have EXACTLY this in

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.