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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:36:42+00:00 2026-06-19T01:36:42+00:00

I have a layered partial scheme and am trying to write DRY code. I

  • 0

I have a layered partial scheme and am trying to write DRY code.
I need to pass a variable into a partial and maintain its array status so that within the partial I can render another partial with the :collection parameter.

on this page I render the 'feed' partial:

 %div.row
    %div.span6
      %h1 Posts 
      /Post feed
      =render 'feed',:locals => {:feed_items => @posts}
    %div.span6
      %h1 Groups
      /Group feed
      =render 'feed', :locals => {:feed_items => @groups}

Here is the 'feed' partial:

%ol
  -if feed_items.first.is_a?(Post)
    =render :partial => 'post_feed_item', :collection => feed_items
  -else
    =render :partial => 'group_feed_item', :collection => feed_items
=will_paginate feed_items

Currently gives me this error:

undefined local variable or method `feed_items' for #<#<Class:0x007fa8e2aa8b00>:0x007fa8e5405390>

UPDATE 1:

real error. final partial doesn’t recognize component of the :collection passed to it:

undefined local variable or method `feed_item' for #<#<Class:0x007fa8e2aa8b00>:0x007fa8e2c6d670>

final partial 'post_feed_item'(layer 3?):

%li.feed_item.row-fluid
  %div.image.span3
    =link_to image_tag(feed_item.assets.empty?  ? '/assets/small.png': feed_item.assets.first.image.url(:small), :alt => feed_item.title), post_url(feed_item)

So there is some problem in the first partial…feed_items isn’t being parsed as an array?

  • 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-19T01:36:44+00:00Added an answer on June 19, 2026 at 1:36 am

    calling

    = render partial: 'post_feed_item', collection: feed_items
    

    will give you a post_feed_item local variable and not a feed_item variable. either you use that or pass in an as option to set the local variable name.

    = render partial: 'post_feed_item', collection: feed_items, as: :feed_item
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a layered worker class that I'm trying to get progress reports from.
I have a layered application. I am trying to determine where to place a
I have some DevExpress BarButtonItem layered on top of one another. So I need
In a standard 3-layered application (Winforms Ui, BLL, DAL) i need to have settings
I have the following code to display an absolutely positioned (layered with z-index) element
I have a quick question about R. I am trying to make a layered
i am trying to set transparency of all windows. I have following code. public
I have a multi-layered PSD, with one specific layer being non-rasterized text. I'm trying
I have multiple IMGs layered on top of each other (position:absolute;top:0;left:0;), and I need
Suppose you have a layered project divided into the Presentation Layer, the Business Layer

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.