3

我有任务,我想要在项目上下文中显示。他们通过哈比姆协会相关联。所以我有三个表格:projects, tasks and projects_tasks如何通过habtm关联设置load_and_authorize_resource?

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 
    ... 

我如何通过habtm关联设置load_and_authorize_resource

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

回答

0

你可能想使你的连接表的模型,使得项目has_many :tasks, :through => : assignments

+0

我会尝试这一点,也许这是要走的路。 – tonymarschall 2012-04-01 10:14:47