app/models/app_container.rb in erp_app-3.0.0 vs app/models/app_container.rb in erp_app-3.0.1
- old
+ new
@@ -1,13 +1,13 @@
class AppContainer < ActiveRecord::Base
has_user_preferences
- belongs_to :user, :dependent => :destroy
+ belongs_to :user
belongs_to :app_container_record, :polymorphic => true
has_and_belongs_to_many :applications
- def preferences()
+ def preferences
self.user_preferences.includes([:preference]).where('user_id = ?', self.user.id).map(&:preference)
end
def get_preference(preference_type_iid)
get_user_preference(self.user, preference_type_iid)
@@ -17,7 +17,13 @@
set_user_preference(self.user, preference_type_iid, preference_option_iid)
end
def setup_default_preferences
#template method
+ end
+
+ class << self
+ def find_by_user(user)
+ AppContainer.where('user_id = ?', user.id).first
+ end
end
end