I have a blog section in my rails app and was wondering what a good way to handle assigning the CSS class active would be, based on the page that would be open.
Should this be done via .erb with if and do statements? It would need to reflect the category the post is in.
Blog Category Table:
create_table "blog_categories", force: :cascade do |t|
t.string "name"
t.integer "parent_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
Posts Table Column: t.integer "category_id" - This is stored to relate to the .id of the cat.
My categories are represented with a parent_id of NULL and subcategories are those with a parent_id set to the .id of the main category.