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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:11:17+00:00 2026-05-15T22:11:17+00:00

One of my helper functions to render partials is not rendering correctly. def render_contact_list

  • 0

One of my helper functions to render partials is not rendering correctly.

    def render_contact_list
      @contact_groups = ContactGroup.find(:all, :conditions => ["user_id = ?", current_user.id])

      @contact_groups.each do |contact_group|
        @contacts = Contact.find(:all, :conditions => ["group_id = ? and Owner_id = ?", contact_group.id, current_user.id])
        render :text => "#{contact_group.name}<br />"
        render(:partial => 'contacts/partials/view_contacts', :collection => @contacts, :as => :contact)
      end
  end

All that displays on the page is

##

When looking at the HTML of the rendered page, it looks like this:

#<ContactGroup:0x103090c78>#<ContactGroup:0x103090b60>

I commented out the block function completely and it still displayed the above.

What am I doing wrong?

Edit: I just realized that the ## is coming from @contact_groups being the last value assigned on the page. It is returning the value and not rendering any of the code within the block.

  • 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-15T22:11:17+00:00Added an answer on May 15, 2026 at 10:11 pm

    Your helper function is returning the list @contact_groups. You need to return the partial instead. You might do it like this (rough example):

    def render_contact_list
      @contact_groups = ContactGroup.find(:all, :conditions => ["user_id = ?", current_user.id])
    
      text = ""
      @contact_groups.each do |contact_group|
        @contacts = Contact.find(:all, :conditions => ["group_id = ? and Owner_id = ?", contact_group.id, current_user.id])
          text << render :text => "#{contact_group.name}<br />"
          text << render(:partial => 'contacts/partials/view_contacts', :collection => @contacts, :as => :contact)
        end
        text
      end
    

    Here, we build a string with all the partially-rendered pieces, then return that string (by mentioning it last). The fact that it worked with and without the block is a coincidence; both the first line of your function and the block evaluate to the same thing.

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

Sidebar

Related Questions

I've tried looking at similar problems, but could not easily find one that helped
I want to create a hidden field and create a link in one helper
I am trying to create a little helper application, one scenario is file duplication
I'm writing C# code that uses the windows IP Helper API. One of the
I got two tables, one of which is a helper of the other. The
This has been working fine, not sure why it's stopped all of a sudden..
I have a helpers.py file which defines about 30 helper functions to be exported
I've created several helper functions which I use when creating templates for Wordpress. An
Whenever I have 2 specific functions, one that I want called upon entry of
I have a directory with some helper functions that should be put into a

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.