small fix to update

This commit is contained in:
Tyler Renelle 2012-02-11 02:43:15 -05:00
parent 2e10d26325
commit c979d24dac

View file

@ -34,8 +34,10 @@ class HabitsController < ApplicationController
def update
@habit = current_user.habits.find(params[:id])
user_stats = params[:habit].delete('user_stats')
@habit.user.update_attributes({:lvl => user_stats['lvl'], :exp => user_stats['exp'], :money => user_stats['money']})
if (params[:habit][:user_stats])
user_stats = params[:habit].delete('user_stats')
@habit.user.update_attributes({:lvl => user_stats['lvl'], :exp => user_stats['exp'], :money => user_stats['money']})
end
respond_to do |format|
if @habit.update_attributes(params[:habit])