Show a tag 5/9


#1

Stuck again. It says there"Then in the Tags controller, add the show action:" ...And I did exactly what was asked, pasted the code into the tags controller file. But no matter where I try to fill in the method 'destinations' it keeps saying that its undefined. Here's the code:

class TagsController < ApplicationController
  def index
    @tags = Tag.all
    end
  def show 
      @tag = Tag.find(params[:id]) 
      @destinations = @tag.destinations 
  end
end

#2

Hi Daniel,

The code you posted works fine for me. Would you mind posting the code you have in app/views/tags/show.html.erb, please?
Thanks! :slightly_smiling:


#3

sure. its

<div class="header">
  <div class="container">
    <img src="http://s3.amazonaws.com/codecademy-content/courses/learn-rails/img/logo-1tm.svg" width="80">
    <h1>BokenjiKan</h1>
  </div>
</div>

<div class="tag">
  <div class="container">
    <h2 class="tag-title">  </h2>

    <div class="cards row">
		

      <!--
      To do: Loop through destinations and display each one with this HTML
      <div class="card col-xs-4">
        destination's image goes here
        <h2> destination's name goes here </h2>
        <p> destination's description goes here </p>
      </div>
      -->

    </div>

  </div>
</div>

#4

there is more :wink:

<div class="header">
  <div class="container">
    <img src="http://s3.amazonaws.com/codecademy-content/courses/learn-rails/img/logo-1tm.svg" width="80">
  </div>
</div>

<div class="tag">
  <div class="container">
    <h2 class="tag-title">  </h2>

    <div class="cards row">
    

    </div>

  </div>
</div>

#5

for some reason it won't show everything. if you want i can also make a screenshot


#6

@kosmotakis Thanks, but no, screenshots don't let me copy/paste the code out of them to test it :slightly_smiling:

See here for how to make code visible:


#7

tried that. doesn't work always on my mac. sometimes works sometimes just doesnt. going to try again later


#8

@kosmotakis Weird :confused:
No worries, though :slightly_smiling: I'll edit your posts for you and take a look to see if I can find the problem :slightly_smiling:


#9

@kosmotakis Well, your index and show code isn't complete, but I don't think that's really your problem.
Could you post the code in config/routes.rb please? (almost definitely the last file I'll need :smile:)


#10

Here it is

´Rails.application.routes.draw do
get '/tags/:id' => 'tags#show', as: :tag
get '/tags' => 'tags#index'´


#11

@kosmotakis Hm, not sure why you're getting anything about "undefined" stuff :confused:
Maybe try again later?


#12

:slightly_smiling: thats what I was thinking. I will let you know if there is a different error at some point :wink:


#13

Hey man. Want to know what the problem was? Like many times it was a missing space:smile:. this is the code that worked `class TagsController < ApplicationController
def index
@tags = Tag.all
end

def show 
@tag = Tag.find(params[:id]) 
@destinations = @tag.destinations 
end

end`


#14

@kosmotakis Great! I'm glad you were able to find the problem :slightly_smiling:
Good luck with the rest of the course!


#15

2 posts were split to a new topic: Stuck on "Show a Tag" 5/9


#17