I have a taggable Game model. And now I want to make a controller to display objects by tags.
I’m able to select a tag by using @tag = ActsAsTaggableOn::Tags.find params[:id]. But how do I retrieve all the games associated with the tag? @tag.games obviously doesn’t work.
You probably don’t need a TagsController.
To get what you’re specifically asking for, you can use:
If the tag is something passed into that controller action you can find it dynamically:
In routes.rb:
In GamesController:
This would allow a user to go to /games/tagged/fps to get a listing of all games tagged as first person shooters, for example (assuming your index template is a general collection listing, anyway