Guest User

Untitled

a guest
Feb 20th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. require 'rubygems'
  2. require 'activerecord'
  3.  
  4. ActiveRecord::Base.establish_connection(
  5. :adapter => "mysql",
  6. :host => "192.168.***.***",
  7. :username => "username",
  8. :password => "password",
  9. :database => "database",
  10. :socket => "/var/lib/mysql/mysql.sock",
  11. :encoding =>"utf8")
  12.  
  13. ArAuto = Module.new
  14. ActiveRecord::Base.connection.tables.each do |table_name|
  15. eval("ArAuto::#{table_name.singularize.camelize} = Class.new(ActiveRecord::Base)")
  16. end
  17.  
  18. # example for contents table
  19. p ArAuto::Content.find(:all,:limit=>3)
Add Comment
Please, Sign In to add comment