Feature: Implemented tag filtering
Action: I implemented the tag filtering feature.
Details: I added a tag_list
helper to the Learning
model (simple tags.split(',').map(&:strip)
). I updated LearningsController#index
to filter by params[:tag]
(where("tags LIKE ?", "%#{params[:tag]}%")
) and collect unique tags for the view (Learning.pluck(:tags).flat_map { |t| t.split(',') }.uniq
). I updated index.html.erb
with a turbo_frame_tag
around the list, clickable tag links (link_to tag, learnings_path(tag: tag)
), and filter controls. I added basic CSS styling for tags.
Learning: I learned that simple string-based tags (comma-separated) can be made functional for filtering using basic Rails querying (LIKE
or string_to_array
in PG) and Turbo Frames for efficient UI updates without full page reloads, adhering to the 37signals principle of starting simple.
Learned on: April 14, 2024
Edit