diff --git a/app/controllers/panel/users_controller.rb b/app/controllers/panel/users_controller.rb index c0a2f5268..7abf6e1f3 100644 --- a/app/controllers/panel/users_controller.rb +++ b/app/controllers/panel/users_controller.rb @@ -65,6 +65,10 @@ class Panel::UsersController < ApplicationController else @user = User.find(params[:id]) @user.destroy + @user.user_attributes.each do |ua| + ua.attribute_values.each(&:destroy) + ua.destroy + end end redirect_to :action => :index diff --git a/app/models/user.rb b/app/models/user.rb index 5e0474151..f71717234 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,6 +10,7 @@ class User field :admin, :type => Boolean, :default => true field :active_roles, :type => Array + has_many :user_attributes has_many :user_roles has_many :user_infos before_save :clean_active_roles diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 21b1880b0..4d9651a1b 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -41,8 +41,8 @@ namespace :dev do urm_2.attribute_models.build( :key => 'major', :locale => true, :i18n_variable_id => var_6.id, :markup => 'text_field', :list_options => [] ) urm_2.save! uim_1 = UserInfoModel.new( :key => 'profile', :i18n_variable_id => var_7.id, :built_in => true ) - uim_1.attribute_models.build( :key => 'family_name', :locale => true, :i18n_variable_id => var_8.id, :markup => 'text_field', :list_options => [] ) - uim_1.attribute_models.build( :key => 'first_name', :locale => true, :i18n_variable_id => var_9.id, :markup => 'text_field', :list_options => [] ) + uim_1.attribute_models.build( :key => 'family_name', :locale => true, :i18n_variable_id => var_8.id, :markup => 'text_field', :list_options => [], :built_in => true ) + uim_1.attribute_models.build( :key => 'first_name', :locale => true, :i18n_variable_id => var_9.id, :markup => 'text_field', :list_options => [], :built_in => true ) uim_1.save! layout = Layout.create!( :name => 'root', :description => 'root', :content => File.open("#{RAILS_ROOT}/lib/template/root.layout").read )