我想在项目环境中显示任务。它们通过habtm协会联系在一起。所以我有三张桌子: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
...
如何通过habtm协会设置load_and_authorize_resource
?
# ???
class TasksController < ApplicationController
load_and_authorize_resource :project
load_and_authorize_resource :task, :through => :project, :shallow => true
...
答案 0 :(得分:0)
您可能希望将表格加入表格has_many :tasks, :through => : assignments