Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stage = Stage.first
- Stage Load (0.9ms) SELECT "stages".* FROM "stages" ORDER BY "stages"."id" ASC LIMIT $1 [["LIMIT", 1]]
- => #<Stage id: 1, name: "Демо Реклама Сев", domain: nil, ip: "188.226.132.181", created_at: "2017-07-06 12:49:24", updated_at: "2017-07-11 23:14:32", db_symbol: "demo", url: "demo.reklama-sev.com">
- model_identifier = "FirmCategory"
- => "FirmCategory"
- class_name = model_identifier + stage.db_symbol.capitalize
- => "FirmCategoryDemo"
- parent_class_name = "Category#{stage.db_symbol.capitalize}"
- => "CategoryDemo"
- Object.const_set(class_name, Class.new(parent_class_name.constantize) {})
- => FirmCategoryDemo (call 'FirmCategoryDemo.connection' to establish a connection)
- class_name.constantize.table_name = "categories"
- => "categories"
- class_name.constantize.establish_connection(stage.db_symbol.to_sym)
- => #<ActiveRecord::ConnectionAdapters::ConnectionPool:0x00000006022500 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x000000060223c0>, @query_cache_enabled=#<Concurrent::Map:0x00000006022348 entries=0 default_proc=#<Proc:0x000000060222f8@/home/flashlight/.rvm/gems/ruby-2.4.0@reklamaagent/gems/activerecord-5.0.3/lib/active_record/connection_adapters/abstract/query_cache.rb:27>>, @spec=#<ActiveRecord::ConnectionAdapters::ConnectionSpecification:0x000000060229d8 @name="FirmCategoryDemo", @config={:adapter=>"postgresql", :encoding=>"unicode", :pool=>5, :username=>"reklamasev", :password=>"X4pT{/&q", :host=>"188.226.132.181", :port=>5432, :database=>"reklamasev_demo"}, @adapter_method="postgresql_connection">, @checkout_timeout=5, @reaper=#<ActiveRecord::ConnectionAdapters::ConnectionPool::Reaper:0x000000060221b8 @pool=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x00000006022500 ...>, @frequency=nil>, @size=5, @thread_cached_conns=#<Concurrent::Map:0x00000006022168 entries=0 default_proc=nil>, @connections=[], @automatic_reconnect=true, @now_connecting=0, @threads_blocking_new_connections=0, @available=#<ActiveRecord::ConnectionAdapters::ConnectionPool::ConnectionLeasingQueue:0x00000006022000 @lock=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x00000006022500 ...>, @cond=#<MonitorMixin::ConditionVariable:0x00000006021fd8 @monitor=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x00000006022500 ...>, @cond=#<Thread::ConditionVariable:0x00000006021f88>>, @num_waiting=0, @queue=[]>>
- FirmCategoryDemo.first
- FirmCategoryDemo Load (81.8ms) SELECT "categories".* FROM "categories" WHERE "categories"."type" IN ('FirmCategoryDemo') ORDER BY "categories"."id" ASC LIMIT $1 [["LIMIT", 1]]
- => nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement