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

  • Home
  • SEARCH
  • 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 8712889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:12:21+00:00 2026-06-13T05:12:21+00:00

To those helping.. Thanks. Still no solution but getting closer. The errors i think

  • 0

To those helping.. Thanks. Still no solution but getting closer. The errors i think are because my “file” evaluates to “app/views/main/show/_partial.html.erb”. and render adds it’s own relative path. So I guess i need to list the file names.. maybe a dir.foreach or dir.glob type command.. i’ll keep digging. THANKS!

I have a directory full of partials I would like to call in a page. So I wrote a loop but it yields errors.

<% Dir["app/views/main/show/*"].each do |file| %>
  <%= render #{file} %>
<% end %>

When I replace the render line with a simple

file

it lists the file names so i know the loop and Dir location work. The problem I THINK is that render is looking for a string. So I’ve tried all sorts of things from searching google and here like the #{file}, creating a variable first, raw,…etc.

also I think render may be looking in a different directory relative the Dir. I’ll try out some stuff there to.

How should I be handling this? I’m up for switching from Dir to Dir.foreach or any other strategy that makes sense.

Thanks.

EDIT: Here’s the solution I’ve implemented (directory path changed from above):

<% Dir["app/views/partials/show/*.html.erb"].each do |file| %>
<p> <%= render 'partials/show/' + File.basename(file,'.html.erb').slice!(1..-1) %></p>
<% end %>
  • 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-13T05:12:22+00:00Added an answer on June 13, 2026 at 5:12 am

    file is already a string, so there is no need to escape. Also, you have to give the full path. This should work:

    <% Dir["app/views/main/show/*"].each do |file| %>
      <%= render :file => Rails.root.join(file).to_s %>
    <% end %>
    

    #{} only works inside double quotes. E.g. "#{file}", but in this case that’s not necessary. You can just use file.

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

Sidebar

Related Questions

Thanks in advance for helping me out (for those who have time and are
I have this code (thanks to those that have been helping so far) It
First of all, thanks everyone for helping yesterday. I've managed to get my report
I've tried everything i can think of and i still can't get the R.java
Those icons you can find in the sdk/platforms/data/res/drawable-hdpi... such as ic_delete. How would you
those of you who read my previous questions may already know this: I'm currently
Those dark spinning progress dialogs in the Amazon and Engadget apps - are those
Those of you familar with activeadmin, you can do something like this in your
Those who invented Android and Java didn't invented for themselves. Since I started developing
For those who deal with microcontroller programming... I want to take a momentary contact

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.