How to configure load_and_authorize_resource via habtm association?
I have tasks that I want to display in the context of a project. They are linked through the 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 customize load_and_authorize_resource
through the habtm association?
# ???
class TasksController < ApplicationController
load_and_authorize_resource :project
load_and_authorize_resource :task, :through => :project, :shallow => true
...
+3
source to share