Hi there,
I have 2 actions that are rather identical:
Put /account/you/update_password
def update_password
@user = current :user
respond_to do |format|
if @user.update_attributes(params[:user])
format.html {redirect_to account_url}
else
format.html {render :action => “edit_password”}
end
end
end
PUT /account/you
Update the user object.
def update
@user = current :user
respond_to do |format|
if @user.update_attributes(params[:user])
format.html {redirect_to account_url}
else
format.html {render :action => “edit”}
end
end
end
The only thing that differs between the 2 is in the “else” part {render
:action => “edit” or render :action => “edit_password”} lines. In the
past
when I have encountered a situation like this I’d use one action, and in
the
forms I’d stick an extra param indicating what action to render if an
error
occurred. Doing that seemed kind of clunky in my opinion.
This seems like something common, and/or simple that I’m just
overlooking.
Is going with the extra param in the form the best route?
Thanks,
Dave