I have a single model:
class Page < ActiveRecord::Base
has_ancestry
validates :slug, :name, uniqueness: true, presence: true
before_validation :generate_slug
def to_param
slug
end
def generate_slug
self.slug = Russian.translit(name).parameterize
end
end
and I'm using ancestry
gem to create tree of pages and subpages, i.e. page can have multiple sub-pages and sub-pages can also have multiple sub-pages, and so on to infinity.
But my problem is that I can't make something is /page-1/page-1-2/page-1-2-1
. All sub-pages have a URL is: /page-1-2
or /page-1-3-1
.
My routes.rb:
Rails.application.routes.draw do
get '/pages' => 'pages#index'
resources :pages, path: "", path_names: { new: 'add' }
root 'pages#index'
end
How to make nested URL?
Thanks!