A navigable has a
slug attribute, which is a unique, human- and URL-friendly string used to identify the model, particularly when requesting the model via a URL.
For example, in the Storefront, the path /pages/foo is routed to
Storefront::PagesController#show, which looks up the requested page by slug:
to_param on a navigable returns the navigable's slug, allowing idiomatic use of Rail's routing helpers, while maintaining "pretty" URLs.
= page_path(@page) / evaluates to "/pages/foo"
A navigable must have a slug, but one will be generated if not provided explicitly. A generated slug is derived from the navigable's name, including an incrementing suffix if needed to ensure uniqueness.
Workarea::Catalog::Category.create!(name: 'Foo').slug # => "foo" Workarea::Catalog::Category.create!(name: 'Foo').slug # => "foo-1"
A navigable has a 1:1 relationship with a taxon, which represents the navigable's position within the site's taxonomy tree.
navigable = Workarea::Catalog::Product.create!(name: 'Foo') taxon = Workarea::Navigation::Taxon.create!(navigable: navigable) navigable.taxon.class # => Workarea::Navigation::Taxon navigable.taxon.name # => "Foo"