I am trying to display subpages from the subpages parent on a subpage.
The code between the lines doesn’t work for me. Does anyone has an
idea what would be a better code?
pages and subpages are in the same controller.
@page = Page.find_by_name(params[:name])
if @page.respond_to?(‘subpages’)
@subpages = @page.subpages
elsif @page.parent.respond_to?(‘subpages’)
@subpages = @page.parent.subpages
end
end
application.html.erb
for page in @page
show link to each page…
end
for page in @subpages
show link to each subpage…
end