Guest User

Untitled

a guest
Apr 12th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. Notes:
  2. Currently this works for me
  3.  
  4. $script/console
  5. >require 'lib/crawler'
  6. >crawl = Crawler.new
  7. >crawl.pull_data
  8.  
  9. #/lib/crawler.rb
  10. require 'scrubyt'
  11. class Crawler
  12. def pull_data
  13. pages = Page.all
  14. ....shortened.....
  15. end
  16.  
  17. I created a rake file
  18. require 'lib/bug'
  19.  
  20. namespace :bug do
  21. desc "crawl pages"
  22. task(:crawl => :environment) do
  23.  
  24. #cant run because scrubyt can load from rake task
  25. crawler = Crawler.new
  26. crawler.pull_data
  27.  
  28. #potential fix by loading via script rather than rake task
  29. #puts `ruby cl_pull_ads.rb`
  30.  
  31. end
  32. end
  33.  
  34. When I run rake task I get
  35.  
  36. stack level too deep
  37. /opt/local/lib/ruby/gems/1.8/gems/scrubyt-0.4.06/lib/scrubyt/utils/ruby_extensions.rb:66:in `write'
  38.  
  39. So works at console but not with rake task...
  40. so I created a runner script but that did not work either
  41.  
  42. #crawl.rb
  43.  
  44. crawler = Crawler.new
  45. crawler.pull_data
  46.  
  47. $script/runner crawl.rb
  48.  
  49. #only problem is now active record does not work
  50. #so I updated it
  51. require 'rubygems'
  52. require 'active_record'
  53. require 'lib/crawler'
  54.  
  55. ActiveRecord::Base.establish_connection(
  56. :adapter => 'mysql',
  57. :database => '',
  58. :username => '',
  59. :password => '',
  60. :host => 'localhost'
  61. )
  62. class Page < ActiveRecord::Base
  63. end
  64. x = Page.new
  65. y Page.all
  66.  
  67. #returns
  68. #/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:260:in `method_missing': undefined method `all' for #<Page:0x19c2038> (NoMethodError)
  69.  
  70. #Summery
  71. So basically when I try to run a ruby script from the command line rails and activerecord is deprecited unless I run it from rake.. but when I run the script from rake scrubyt die with stack problem...
  72.  
  73. how can I get a full rails stack loaded and not use rake?
  74.  
  75. Thanks!!!
Add Comment
Please, Sign In to add comment