-1

I have a User model with the following attributes:
name
age
ìmage
email
password

I want the user to edit/update the first three attributes in one view and the other two in another.

Do I break the RESTful pattern if I duplicate the edit/update actions and routes?

What could be a better solution?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Fellow Stranger
  • 32,129
  • 35
  • 168
  • 232

1 Answers1

0

Use one action with extra parameter, like /user/1/edit and /user/1/edit?step=2.

If you are using some kind of wizard, try to extract it in a separate class:

# controller
def update 
  @step == params[:step].presence or Wizard::FIRST_STEP # = 1
  @wizard = Wizard.new(user, @step)
  if @wizard.update(params)
  ...
end

def edit
  ...
  render @wizard.partial # depends on step params 
  ...
organium
  • 59
  • 10