-
-
Save danreedy/7124928 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UserController < ApplicationController | |
| def create | |
| @user = User.create(UserInput.create(params)) | |
| end | |
| def update | |
| @user = User.find(params[:id].to_i) | |
| @user.update_attributes(UserInput.update(params)) | |
| end | |
| def update_password | |
| @user = User.find(params[:id].to_i) | |
| @user.update_attributes(UserInput.update_password(params)) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UserInput | |
| def initialize(p) | |
| @params = p | |
| end | |
| class << self | |
| def create(p) | |
| p.require(:user).permit([ :name, :email, :password, :password_confirmation ]) | |
| end | |
| def update(p) | |
| p.require(:user).permit([ :name, :email ]) | |
| end | |
| def update_password(p) | |
| p.require(:user).permit([ :password, :password_confirmation ]) | |
| end | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a quick update to the source pattern, completely untested but wanted to put it down while I was thinking about it.