Created
November 20, 2009 22:33
-
-
Save ryanb/239846 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
# Example of nested resource with CanCan | |
class CommentsController < ApplicationController | |
before_filter :load_and_authorize_resource | |
# ... | |
protected | |
def load_resource | |
@article = Article.find(params[:article_id]) | |
unless params[:action] == "index" | |
if params[:id] | |
@comment = @article.comments.find(params[:id]) | |
else | |
@comment = @article.comments.build(params[:talk]) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment