Skip to content

Commit

Permalink
add table format
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklynhma committed Oct 19, 2023
1 parent d9ccbd1 commit a86b07a
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions sites/intro-to-rails/allow_people_to_vote.step
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,43 @@ steps {
MARKDOWN
end

step "Add the button to the view" do
step "Add the button to the view and add a table format" do

message "Edit `app/views/topics/index.html.erb` so that the bottom loop looks like this:"
message "Edit `app/views/topics/index.html.erb` so that it looks like this:"

source_code :erb, <<-HTML
<% @topics.each do |topic| %>
<tr>
<td><%= topic.title %></td>
<td><%= topic.description %></td>
<td><%= pluralize(topic.votes.count, "vote") %></td>
<td><%= button_to '+1', upvote_topic_path(topic), method: :post %></td>
<td><%= link_to 'Show', topic %></td>
<td><%= link_to 'Edit', edit_topic_path(topic) %></td>
<td><%= link_to 'Destroy', topic, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
<p style="color: green"><%= notice %></p>

<h1>Topics</h1>

<div id="topics">
<table>
<tr>
<th> Topic </th>
<th> Description</th>
<th> Votes count</th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
</tr>

<% @topics.each do |topic| %>
<tr>
<td><%= topic.title %></td>
<td><%= topic.description %></td>
<td><%= pluralize(topic.votes.count, "vote") %></td>
<td><%= button_to '+1', upvote_topic_path(topic), method: :post %></td>
<td><%= link_to 'Show', topic %></td>
<td><%= link_to 'Edit', edit_topic_path(topic) %></td>
<td><%= link_to 'Destroy', topic, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>

</table>
</div>

<%= link_to "New topic", new_topic_path %>
HTML

message <<-MARKDOWN
Expand Down

0 comments on commit a86b07a

Please sign in to comment.