Refactor abilities. Added ProjectUpdate context. Fixed few bugs with namespaces
This commit is contained in:
parent
a1ffc673b9
commit
eb1004f789
18 changed files with 127 additions and 53 deletions
|
@ -24,13 +24,9 @@ class Admin::ProjectsController < AdminController
|
|||
end
|
||||
|
||||
def update
|
||||
owner_id = params[:project].delete(:owner_id)
|
||||
status = ProjectUpdateContext.new(project, current_user, params).execute(:admin)
|
||||
|
||||
if owner_id
|
||||
@project.owner = User.find(owner_id)
|
||||
end
|
||||
|
||||
if @project.update_attributes(params[:project], as: :admin)
|
||||
if status
|
||||
redirect_to [:admin, @project], notice: 'Project was successfully updated.'
|
||||
else
|
||||
render action: "edit"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue