Advertisement
Guest User

Untitled

a guest
Jul 30th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. require 'rubygems'
  2. require_gem 'activerecord'
  3.  
  4. class BooksToDo < ActiveRecord::Base
  5. set_table_name "books"
  6. end
  7.  
  8. class UsersInfo < ActiveRecord::Base
  9. set_table_name "users"
  10. end
  11.  
  12. # This gets my database config
  13. @dbs = YAML::load(ERB.new(IO.read("/home/myname/config/database.yml")).result)
  14.  
  15. # to slurp records into production db, change this line to production.
  16. curr_db = @dbs["development"]
  17.  
  18. # these parameters are mysql-specific, figure out how to improve
  19. ActiveRecord::Base.establish_connection(:adapter => curr_db["adapter"], :database => curr_db["database"],:host => curr_db["host"], :username => curr_db["username"], :password => curr_db["password"])
  20.  
  21. generate = BooksToDo.find(:all, :conditions => "status=0")
  22.  
  23. for book in generate
  24.  
  25. # do whatever
  26.  
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement