ryanb/cancan — Issue #550: How to pass user_id to nested_resource?
Author: tonymarschall
Created: 2012-01-19 18:47:43+00:00
State: open

I have the following models:

class User < ActiveRecord::Base
has_many :responsibilities, :dependent => :destroy
has_many :projects, :through => :responsibilities
has_many :tasks, :dependent => :destroy
...
class Project < ActiveRecord::Base
has_many :tasks, :dependent => :destroy
...
class Task < ActiveRecord::Base
belongs_to :project
belongs_to :user
...

The tasks controller starts like this:

class TasksController < ApplicationController
load_and_authorize_resource :project
load_and_authorize_resource :task, :through => :project
...

The task model has a name, user_id and project_id. When adding a new Task (only an input for name) the project_id gets automatically passed to model/table but not the user_id. Can somebody give a hint on howto do this?

Thanks