ruby-on-rails – div_for:NoMethodError

I am trying a ror tutorial, and I encountered 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 index.html.erb so that the part is not needed but it does not work properly.

Please refer to the code below.

index .html.erb:

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

NoMethodError in player#index

This is a direct translation of your code:

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

Rendering: Partially given A collection (@players this case) will traverse the collection one by one and render parts for you.

But the rendering collection will also provide you with counter and interval templates.

I am trying a 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 index.html.erb so that the part is not needed but it does not work properly.< /p>

Please refer to the code below.

index.html.erb:

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

NoMethodError in player#index

< p>

This is a direct translation of your code:

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

Rendering: Partially given a collection (@players this case) will traverse the collection one by one and render the parts for you.

But the rendering collection will also provide you with counter and interval templates.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3295 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.