Permalink
Browse files

index and eager loading

  • Loading branch information...
1 parent b6a1dc8 commit 03fc5203b98b17e829840379427c7d04115990f5 @mooktakim committed Dec 9, 2010
Showing with 3 additions and 0 deletions.
  1. +1 −0 app/models/omnisocial/login_account.rb
  2. +2 −0 lib/generators/omnisocial/templates/migration.rb
@@ -2,6 +2,7 @@ module Omnisocial
class LoginAccount < ActiveRecord::Base
belongs_to :user, :class_name => '::User'
serialize :user_hash
+ default_scope :include => :user
before_save do
self.login = self.remote_account_id if self.login.blank?
@@ -30,9 +30,11 @@ def self.up
add_index :login_accounts, :user_id
add_index :login_accounts, :type
+ add_index :login_accounts, [:type, :remote_account_id], :name => 'type_remote_acc_id'
end
def self.down
+ remove_index :login_accounts, :name => 'type_remote_acc_id'
remove_index :login_accounts, :type
remove_index :login_accounts, :user_id
drop_table :login_accounts

0 comments on commit 03fc520

Please sign in to comment.