Refactor abilities. Added ProjectUpdate context. Fixed few bugs with namespaces

This commit is contained in:
Dmitriy Zaporozhets 2012-11-29 07:29:11 +03:00
parent a1ffc673b9
commit eb1004f789
18 changed files with 127 additions and 53 deletions

View file

@ -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"