Skip to content

Commit

Permalink
permissions-associations
Browse files Browse the repository at this point in the history
## Associations

Although we have modelled the assignment of tasks to users, at the moment there is no way for the user to set these assignments. We'll add that to the task edit page. Create a task and browse to the edit page - only the description is editable. Hobo does provide support for "multi-model" forms, but it is not active by default. To specify that a particular association should be accessible to updates from the form, you need to declare `:accessible => true` on the association. In `task.rb`, edit the `has_many :users` association as follows:

SHOW_PATCH

Without that declaration, the permission system was reporting that
this association was not editable. Now that the association is
"accessible", the permission system will check for create and destroy
permission on the join model `TaskAssignment`. As long as the current
user has those permissions, the task edit page should now include a
nice javascript powered control for assigning users in the edit-task
page.

Right now the only people who have this permission are the site
administrators.  (The first user who signs up automatically becomes
a site administrator).  We'll add permissions for other users later on
in [Project Ownership](#project_ownership).
  • Loading branch information
bryanlarsen committed Nov 14, 2011
1 parent ef816e4 commit d837d8d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/task.rb
Expand Up @@ -10,7 +10,7 @@ class Task < ActiveRecord::Base
belongs_to :story

has_many :task_assignments, :dependent => :destroy
has_many :users, :through => :task_assignments
has_many :users, :through => :task_assignments, :accessible => true, :dependent => :destroy

# --- Permissions --- #

Expand Down

0 comments on commit d837d8d

Please sign in to comment.