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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:02:34+00:00 2026-06-18T08:02:34+00:00

Does the render partial function take any type of collection? I tried passing a

  • 0

Does the render partial function take any type of collection? I tried passing a Set (@dogs) in and it doesn’t seem to work:

<%= render(:partial => "dog", :collection => @dogs, :as => :dog) %>  

I tried looking it up on the docs http://guides.rubyonrails.org/layouts_and_rendering.html but it doesn’t seem to suggest any limitation on sets… Is there something I have missed or another way to find out?

Thanks.

PS But when I tried to convert the very set to an array and it worked.

  • 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-18T08:02:36+00:00Added an answer on June 18, 2026 at 8:02 am

    It won’t work with a set, because the PartialRenderer#collection method attempts to coerce the collection to an array using to_ary:

    def collection
      if @options.key?(:collection)
        collection = @options[:collection]
        collection.respond_to?(:to_ary) ? collection.to_ary : []
      end
    end
    

    However Sets do not implement to_ary, so, as you have found, you must pass the collection like this:

    :collection => @dogs.to_a
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ryan Bates' nifty_scaffolding, for example, does this edit.html.erb <%= render :partial => 'form' %>
Why when I set enabled=false on a button does it not render correctly in
Here's my biopsis Works : :plain console.log(#{escape_javascript(render(@job_charge).html_safe)}); Does not work ( but should? )
I am trying to render a partial on a collection with <%= render @posts
When I render a partial which does not exists, I get an Exception. I'd
I'm having some difficulties creating a javascript appointment style calendar. While it does render,
Why does WPF render differently on Windows XP vs Windows 7? I'm using .NET SP1 on
Why does this graphml file below does not render the node color properly in
I embed text in textfield, but sometimes it does not render using htmltext. if
Does anybody know why the same code from this page http://emacsformacosx.com/ would not render

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.