Associations I

Show a destination

Nice job! The app displays all destinations that belong to a tag. How does this work?

  • When a user visits http://localhost:8000/tags/1, the route get '/tags/:id' => 'tags#show' sends this request to the Tags controller's show action with {id: 1} in params.
  • The @destinations = @tag.destinations retrieves all the destinations that belong to the tag, and stores them in @destinations. The has_many / belongs_to association lets us query for destinations like this.
  • The tag and its destinations are sent to the view to be displayed.
Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.