Skip to content

Instantly share code, notes, and snippets.

@goncalossilva
Created August 25, 2011 16:21
Show Gist options
  • Select an option

  • Save goncalossilva/1171066 to your computer and use it in GitHub Desktop.

Select an option

Save goncalossilva/1171066 to your computer and use it in GitHub Desktop.
class Ability
include CanCan::Ability
def initialize(user)
can :create, Comment, :post => { :published => true }
end
end
class CommentsController < ApplicationController
load_and_authorize_resource
def create
@comment.save
end
end
<%= form_for @post.comments.new do |f| %>
...
<% end %>
@goncalossilva

Copy link
Copy Markdown
Author

Yes, I have nested routes. Thanks for clarifying!

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