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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:02:44+00:00 2026-05-22T20:02:44+00:00

I am trying an ror tutorial and I came across the following line of

  • 0

I am trying an ror tutorial and I came across the following line of code:

index.html.erb:

<%= render :partial => @players %>

_player.html.erb:

<% div_for player do %>
<%= player.FNAME %> <%= player.SURNAME %>
<% end %>

players_controller.rb:

def index
    @players = Player.all(:order => "FNAME")
    respond_to do |format|
      format.html
    end
end

I want to modify the index.html.erb so that there is no need for a partial but it’s not working properly.

Please see code below.

index.html.erb:

<% div_for @players do %>
<%= @player.FNAME %> <%= @player.SURNAME %>
<% end %>

NoMethodError in Players#index

  • 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-22T20:02:45+00:00Added an answer on May 22, 2026 at 8:02 pm

    This is a direct translation of your code:

    <% @players.each do |player| %>
      <% div_for player do %>
        <%= player.FNAME %> <%= player.SURNAME %>
      <% end %>
    <% end %>
    

    The render :partial given a collection (@players this case) would walk through the collection one by one and render the partial for you.

    But rendering a collection also gives you a counter and spacer template too.

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

Sidebar

Related Questions

for some reasons I am trying to translate the following RoR view code to
I am currently following Michael Hartl's tutorial on RoR and am trying to get
I'm trying to learn RoR following this tutorial and I'm currently in chapter 3.
I'm following along the Rails for Zombies tutorial trying to get the gist of
I am following Michael's ROR tutorial and creating user authentication system. There is an
Just started ROR Lynda Tutorial, Error while trying to execute the rails server in
I'm trying to get RoR running on bluehost. I followed a tutorial to get
im learning RoR atm and im trying to code a calculator webapp. The thing
Absolute RoR newbie here, I'm trying to render out multiple leagues in a loop,
I'm trying to setup my charset in a html view in a RoR application.

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.