Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Notes:
- Currently this works for me
- $script/console
- >require 'lib/crawler'
- >crawl = Crawler.new
- >crawl.pull_data
- #/lib/crawler.rb
- require 'scrubyt'
- class Crawler
- def pull_data
- pages = Page.all
- ....shortened.....
- end
- I created a rake file
- require 'lib/bug'
- namespace :bug do
- desc "crawl pages"
- task(:crawl => :environment) do
- #cant run because scrubyt can load from rake task
- crawler = Crawler.new
- crawler.pull_data
- #potential fix by loading via script rather than rake task
- #puts `ruby cl_pull_ads.rb`
- end
- end
- When I run rake task I get
- stack level too deep
- /opt/local/lib/ruby/gems/1.8/gems/scrubyt-0.4.06/lib/scrubyt/utils/ruby_extensions.rb:66:in `write'
- So works at console but not with rake task...
- so I created a runner script but that did not work either
- #crawl.rb
- crawler = Crawler.new
- crawler.pull_data
- $script/runner crawl.rb
- #only problem is now active record does not work
- #so I updated it
- require 'rubygems'
- require 'active_record'
- require 'lib/crawler'
- ActiveRecord::Base.establish_connection(
- :adapter => 'mysql',
- :database => '',
- :username => '',
- :password => '',
- :host => 'localhost'
- )
- class Page < ActiveRecord::Base
- end
- x = Page.new
- y Page.all
- #returns
- #/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)
- #Summery
- 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...
- how can I get a full rails stack loaded and not use rake?
- Thanks!!!
Add Comment
Please, Sign In to add comment