Trying to configure Cancan in my application and have problems with my PostsController .
In a nutshell, when Post is created, I would like it to be associated with current_user , so my create action looks something like this:
class PostsController < ApplicationController before_filter :login_required, :except => [:index, :show] load_and_authorize_resource ... def create # @post = Post.new(params[:post]) # <-- covered by load_and_authorize_resource @user = current_user @post = @user.posts.create(params[:post]) respond_to do |format| ... end ... end
I'm not quite sure what to do with load_and_authorize_resource (other than the obvious). But what to do in such a situation? Do I need to override load_and_authorize_resource for the create action? or is there another way (read: better) to download the @user and THEN download by creating @post ?
source share