0

I'm following a Ruby on Rails step-by-step and at some step I get a rather different output from the video in the tutorial, even though as far as I can see my code and the tutorial's are exactly the same.

Here is the related code (in file app/views/projects/show.html.erb) :

<p id="notice"><%= notice %></p>

<p>
  <strong> <%= @project.name %> </strong>
</p>

<p>
  <strong>Ends at:</strong>
  <%= @project.ends_at %>
</p>

<h2>Tasks for this project </h2>

<ul>
<%= @project.tasks.each do |task| %>
<li>
<%= check_box_tag "task_done_#{task.id}", "", task.done %>
<%# <%= link_to task.title, task %> 
<%= task.title %>
</li>
<% end %>
</ul>

<%= link_to 'Edit', edit_project_path(@project) %> |
<%= link_to 'Back', projects_path %>

Here is my output :

enter image description here

and the output in the tutorial video :

enter image description here

Why does Ruby on Rails output the task object's description ? I cannot see any place in my code where I tell it to.

Ewan Delanoy
  • 1,276
  • 2
  • 13
  • 31

1 Answers1

3

You need to remove = in this line <%= @project.tasks.each do |task| %>

<ul>
<% @project.tasks.each do |task| %>
<li>
<%= check_box_tag "task_done_#{task.id}", "", task.done %>
<%# <%= link_to task.title, task %> 
<%= task.title %>
</li>
<% end %>
</ul>

Small Note:

<% %> - Executes the code.

<%= %> - Prints the Output.

Pavan
  • 33,316
  • 7
  • 50
  • 76