3

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

resources :projects do
  resources :tasks
end

class Project < ActiveRecord::Base
  has_and_belongs_to_many :tasks
  ...

class Task < ActiveRecord::Base
  has_and_belongs_to_many :projects
  ...

How can i setup load_and_authorize_resource through a habtm association?

# ???
class TasksController < ApplicationController
  load_and_authorize_resource :project
  load_and_authorize_resource :task, :through => :project, :shallow => true
  ...
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
tonymarschall
  • 3,862
  • 3
  • 29
  • 52

1 Answers1

0

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

maletor
  • 7,072
  • 7
  • 42
  • 63