in the sample below:
class BookLib < ActiveRecord::Base
self.abstract_class = true
end
since abstract_class is set to true, this model class shifts to be a fade one(no table will be create for it), why we need a fade model in our project? yeah , we do need, it's powerful air in some cases.
let's assume a situation: we gonna request a batches data of book, the problem is these data were stored into another independent db. so how we touch them in our project.
let's do it like these:
class BookLib < ActiveRecord::Base
self.abstract_class = true
establish_connection("db_#{RAILS_ENV}".to_sym)
validates_presence_of :name
end
class BookTag < BookLib; end
class Book < BookLib; end
in these way, when we gonna CRUD booktag and book , the project will establish connection first.
class BookLib < ActiveRecord::Base
self.abstract_class = true
end
since abstract_class is set to true, this model class shifts to be a fade one(no table will be create for it), why we need a fade model in our project? yeah , we do need, it's powerful air in some cases.
let's assume a situation: we gonna request a batches data of book, the problem is these data were stored into another independent db. so how we touch them in our project.
let's do it like these:
class BookLib < ActiveRecord::Base
self.abstract_class = true
establish_connection("db_#{RAILS_ENV}".to_sym)
validates_presence_of :name
end
class BookTag < BookLib; end
class Book < BookLib; end
in these way, when we gonna CRUD booktag and book , the project will establish connection first.