【发布时间】:2012-04-07 11:14:51
【问题描述】:
我有想要在项目上下文中显示的任务。它们通过 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
...
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 authorization cancan has-and-belongs-to-many