You have a blog application and on the index page you have a list with all posts. A post belongs to a category so you want to have a dropdown to filter the posts per category.
The first thing we need to do is set a variable to hold the available categories:
Now we need a form with the dropdown to send the category_id that we want to filter:
If we select a category, it will send the category_id in the params to the PostsController Index action.
The last step is to modify this action to display the filtered posts: