我有一些任务需要在项目上下文中显示。它们通过 habtm 关联进行关联。因此,我有三个表:projects、tasks 和 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
...