Small cleanup on userStats assignment

This commit is contained in:
Tyler Renelle 2012-02-11 02:31:33 -05:00
parent e2429632a1
commit 2e10d26325
2 changed files with 3 additions and 8 deletions

View file

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

View file

@ -5,7 +5,7 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
attr_accessible :email, :password, :password_confirmation, :remember_me, :lvl, :exp, :money
has_many :habits, :dependent => :destroy
has_many :rewards, :dependent => :destroy