resources :posts do
resources :files, controller: 'posts/files'
end
resources :files
# posts/files_controller.rb
class Posts::FilesController < ApplicationController
def index
@posts = Post.find(params[:post_id])
@files = @post.files
end
...
end
# files_controller.rb
class FilesController < ApplicationController
def index
@files = Files.all
end
...
end