Created
September 18, 2010 15:17
-
-
Save mikeymicrophone/585745 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentsController | |
def index | |
@comments = if params[:book_id] | |
@scope_object = Book.find(params[:book_id]) | |
@scope_object.comments | |
elsif params[:article_id] | |
@scope_object = Article.find(params[:article_id]) | |
@scope_object.comments | |
else | |
Comment.all | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Does Rails 3 provide any way to get the scope object without using a plugin like resourcelogic? Assume we are using nested routes like book_comments_path(@book) | |
What's the cleanest way to always get the comments scoped when you have a lot of different models that have comments? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment