# Code maintenance OP-8370 - Remove duplicate code between PermittedParams and service contracts

Project: OpenProject
Status: new
URL: https://community.openproject.org/work_packages/OP-8370

## OPEN POINTS

_No work packages_

## Subtasks

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Designer |  |
| Developers |  |
| Requires doc change | No |
| Date |  |
| Priority | Medium |
| Target versions |  |
| Sprint |  |
| Backlog bucket |  |
| Module |  |
| Accessibility | No |
| List |  |
| Labels |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| Work |  |
| Remaining work |  |

## Description

I put this here for a general discussion. I assign version 11.3. However, we should feel free to move it. 

**General idea:**  
Currently much code in a service contract is duplicated in `PermittedParams`.

What stops us to use a service contract's  `:writable_attributes` to allow ActiveSupport params for mass assignments? If the contracts are correct -- what I hope -- then their answers shall be identical to those provided by PermittedParameters. 

So in case of a user update the UsersController could simply do a:  
`params.require(:user).permit(Users::UpdateContract.new(@user, User.current).writable_attributes)`

That way we could demolish  `PermittedParams` model by model and improve/foster service and contracts coverage
