How to configure load_and_authorize_resource via habtm association?

I have tasks that I want to display in the context of a project. They are linked through the habtm association. So I have three tables: projects, tasks and projects_tasks


resources :projects do
  resources :tasks

class Project < ActiveRecord::Base
  has_and_belongs_to_many :tasks

class Task < ActiveRecord::Base
  has_and_belongs_to_many :projects


How can I customize load_and_authorize_resource

through the habtm association?

# ???
class TasksController < ApplicationController
  load_and_authorize_resource :project
  load_and_authorize_resource :task, :through => :project, :shallow => true



source to share

1 answer

You might want you to join the table to a model such that Project has_many :tasks, :through => : assignments



All Articles