Skip to content

Commit

Permalink
Merge branch 'hotfix/0.4.2_fix.4'
Browse files Browse the repository at this point in the history
* hotfix/0.4.2_fix.4:
  fix updating account
  • Loading branch information
kalashnikovisme committed Sep 21, 2015
2 parents 9486beb + 0fe7670 commit 9debbc0
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions app/controllers/web/users/account_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,20 @@ def index
end

def update
if params[:user]
@user = User.find params[:id]
@user_form = UserForm.new @user
@user_form.submit params[:user]
if @user_form.save
redirect_to account_path
else
redirect_to account_path
end
elsif params[:member] || params[:questionary]
@member = Member.find params[:id]
@member_form = MemberForm.new @member
@member_form.submit params[:member]
if @member_form.save
redirect_to account_path
else
redirect_to account_path
end
#FIXME more elegant solution
model_name = :user
[:member, :questionary].each do |name|
model_name = name if params[name]
end
model = model_name.to_s.camelize.constantize
model_form = "#{model_name.to_s.camelize}Form".constantize
@user = model.find params[:id]
@user_form = model_form.new @user
@user_form.submit params[model_name]
if @user_form.save
redirect_to account_path
else
redirect_to account_path
end
end
end

0 comments on commit 9debbc0

Please sign in to comment.