Skip to content

Instantly share code, notes, and snippets.

@ryanb
Created November 20, 2009 22:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanb/239846 to your computer and use it in GitHub Desktop.
Save ryanb/239846 to your computer and use it in GitHub Desktop.
# 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