Destroy user_attributes and attribute_values when a user is destroyed
This commit is contained in:
parent
83bbd77d96
commit
43d87ecf98
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 )
|
||||
|
|
Reference in New Issue