Bass-music issue

hello guys, In the bass-music project, album list is being displayed twice on the page and I wasn’t able to find the error. I hope somebody knows the solution

here’s my code:


class AlbumsController < ApplicationController
  def index
  @albums = Album.all

def show
  @album = Album.find(params[:id])
  @tracks = @album.tracks
<!-- show.html -->

<div class="show row">
  <div class="cover col-md-4"><img src="<%= @album.cover %>"></div>

  <div class="col-sm-8">
    <h3 class="album-title"><%= @album.title %></h3>
    <p class="album-artist"><%= @album.artist %></p>

     Loop through each track and display each one with this HTML

<% @tracks.each do |track| %>
    <div class="track row">
      <div class="name col-md-8"><%= %></div>
      <div class="minutes col-md-4"><%= track.minutes %>min</div>
<% end %>

<!-- index.html -->

<div class="row">
  <% @albums.each do |album| %>
<div class="col-md-3">
     <%= link_to(album) do %>
    <div class="thumbnail">
      <img src="<%= album.cover %>">
      <div class="caption">
        <h3 class="title"><%= album.title %></h3>
        <p class="artist"><%= album.artist %></p>
    <% end %>
  <% end %>

Rails.application.routes.draw do
  resources :albums
  root 'albums#index'
  get 'albums' => 'albums#show'

Link please. Much simpler to debug if we can read the instructions and test your code.

Hi mtf ,

here’s link to CC instructions:

and to the code:

1 Like

@anya.ruby Which URL shows the album list twice?

You should remove this line from your routes.rb file, since resources :albums already gives it a show route:

get 'albums' => 'albums#show'

The rest of your code looks alright. Would you mind posting the entire file contents for whichever page has the problem?

1 Like

Hi zystvan, thank you for checking it, I removed this line of code but the content is still somehow appearing twice on the page, it looks like this :

I created the app locally, so the entire code can be found under the link [–]

Running your code on my machine only shows each album once, making me think they may have gotten duplicated in the database, probably by you running rails db:seed twice. Try deleting the database, then creating a new one and bringing the data back in by running these commands in the terminal:

$ rails db:drop
$ rails db:create
$ rails db:migrate
$ rails db:seed 

(make sure you’re in the right directory when you run them)

1 Like

@zystvan, you were right, it helped! I had some issues with running the command rails db: drop (couldn’t be executed due to some permission issues) but rake db: setup solved it for me. Thank you a lot!!! Appreciate your help!


This topic is solved.