Skip to content

Instantly share code, notes, and snippets.

@nicolaslazartekaqui
Last active August 29, 2015 13:57
Show Gist options
  • Save nicolaslazartekaqui/9832333 to your computer and use it in GitHub Desktop.
Save nicolaslazartekaqui/9832333 to your computer and use it in GitHub Desktop.
# files_controller.rb
class FilesController < ApplicationController
def index
@files = Files.all
end
...
end
# posts/files_controller.rb
class Posts::FilesController < ApplicationController
def index
@posts = Post.find(params[:post_id])
@files = @post.files
end
...
end
resources :posts do
resources :files, controller: 'posts/files'
end
resources :files
@nicolaslazartekaqui
Copy link
Author

this way you prevent some conditionals are made to happen your action and keeps the controller most organized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment