Other Pages

Expand All

Clean Up Links On The Topics List

Goals

    Our app is nearly done! The main topics listing page is pretty busy. There are a lot of links that aren't necessary.

    Let's clean up the topics list page by doing the following:

  • Remove the 'show' link

  • Remove the 'edit' link

  • Change 'destroy' to 'delete'

Steps

Step 1: Remove the 'show' and 'edit' links

Open app/views/topics/index.html.erb and remove these two lines:

<td><%= link_to 'Show', topic %></td>
<td><%= link_to 'Edit', edit_topic_path(topic) %></td>

Step 2: Change 'destroy' to 'delete'

Change the line with the word 'Destroy' to this:

<td><%= link_to 'Delete', topic, method: :delete, data: { confirm: 'Are you sure?' } %></td>

Step 3: Confirm your changes

Now save your file and try reloading in your browser to see the changes.

Explanation

  • The two links we removed were show and edit. We did this because the title now links to the show page and from the show page you can reach the edit page.

  • The second change we made was to make the link text 'Delete' instead of destroy.

Three key words

Find a partner and decide on three key words from this section. Write each word down on a sticky note, then put them all on a bit of paper.

If some of the words made you frown, wave at a teacher and talk to them about it.

Deploying

Before the next step, you could try deploying your app to Heroku!

Next Step:

Back to Make The Topic Title A Link

If you find something that could be improved, please make a pull request or drop us a note via GitHub Issues (no technical knowledge required).

Source: https://github.com/RailsBridge-CapeTown