5. Show a Tag / Association I


#1


All code sems to be correct (sometimes already written ?) yet it’s not accepted

ERROR MESSAGE : undefined method `destination_path’ for #<#Class:0x00000004867820:0x0000000485f120>7

https://www.codecademy.com/courses/learn-rails/lessons/one-many/exercises/one-many-show-tag?action=lesson_resume

What Destination Path has to do with my code ?

Thanks all !


#2

Hi @slibre2,

You’re using the destination_path helper in the code in your screenshot. You’ll need to make sure it’s defined in your config/routes.rb file


#3

Hello Zystvan ,
Do you mean that destination_path must be written in config/routes.rb file ?
thanks hc!


#4

Yes, it’ll probably need to look about like this:

get '/destinations/:id' => 'destinations#show', as: :destination_path

#5

Hi Zystvan ,
I m afraid it’s refused . It doesn’t work . Look :
https://www.codecademy.com/courses/learn-rails/lessons/one-many/exercises/one-many-show-tag?action=lesson_resume


According to me problem is different : it is the way the code was written in app/views/tags/show.html.erb file . A mistake in Div Class . The code was not written in the good one .What do you think about that ?


#6

My bad, the _path or _url will be added automatically by Rails, so it should look like this instead:

get '/destinations/:id' => 'destinations#show', as: :destination

And you’ll continue to use it as destination_path(d), like your first screenshot shows. The class name shouldn’t be the problem here.


#7

https://www.codecademy.com/courses/learn-rails/lessons/one-many/exercises/one-many-show-tag?action=lesson_resume
get ‘/destinations/:id’ => ‘destinations#show’, as: :destination is already in config/route.rb
and it still doesn’t work ??? As you can see it here:


#8

@slibre2 The last part of the line needs to be just as: :destination, not as: :destination_path.


#9

Thanks Zystvan ! It works ! (I understood) . I thought it was a file mistake . It was a syntaxe mistake , as most of the time .
Thanks very much for your help ! hc !


#10

This topic is solved.