Thnaks for helping John, The class I'm creating an instance of is used as part of the background_jobs process.
After your comments I thought this might be part of the problem, so I created the most simple class I could, that doesn't involve background_jobs (or anything at all), but still this doesn't work. I'm now thinking it might be to do with inheritance, and / or namespacing If I create a new file test_root_instantiate.rb in the controllers directory, and define it like this (empty) class TestRootInstantiate < ApplicationController end Then in my scrapers class (which is in /controllers/admin/events/ scrapers_controller.rb) I CAN create an instance of this with @test_instantiate = TestRootInstantiate.new This works yay! However, if I make a similar class called test_admin_instantiate.rb in the admin directory, and define the class like this: class Admin::TestAdminInstantiate < AdminController end With name-spacing, and inheriting from AdminController, which in turn inherits from ApplicationController. now in the same place, when I try to run @test_admin_instantiate = TestAdminInstantiate.new it fails - boo. I get this grammatically incorrect error: A ArgumentError occurred in scrapers#scrape_one: Admin is not missing constant TestAdminInstantiate! .bundle/gems/ruby/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:479:in `load_missing_constant' ------------------------------- Request: ------------------------------- * URL : http://...../admin/events/scrapers/6/scrape_one * IP address: xxxx * Parameters: {"action"=>"scrape_one", "id"=>"6", "controller"=>"admin/events/scrapers"} * Rails root: /app So I'm thinking it's something to do with referencing files in different folders. But I've got all the name spacing in the class definitions, if I didn't it certainly wouldn't work in dev mode either. The other thing I thought of was that with these files I didn't create them through the command line, as often classes are created, with 'rails generate controller xyz' I made them by just creating a new file in the text editor called test_admin_instantiate.rb and filling it full of stuff. Is there some rails magic that happens in generating controllers that allows other classes to see their header files or something? I realise I may be stepping into 'rails' forum territory here, but it's only when running on heroku that it stops working. (and I'm guessing you lot know a thing or 2 about rails as well!) Thanks, Michael On Jan 23, 3:33 pm, John McCaffrey <[email protected]> wrote: > Is there anything special about the hierarchy for that class? is it related > to any plugins? > > Are there other classes that you can't instantiate? Is there a commonality > among them? (if its just this one, is there something special about it? can > you strip out that difference and try again?) > > I saw a similar issue someone complained of, when loading a plugin that had > submodules. If this class is related to some other plugins or libraries, > see what is going on there. (and post back) > > On Sun, Jan 22, 2012 at 4:20 PM, Michael Baldock > <[email protected]>wrote: > > > > > > > > > > > Just to go back to the original question though, is there any reason > > why making an instance of a class with > > > @class_instance = Class.new > > > might not work on heroku in production mode, but work locally in > > development mode. > > > Or are there too many reasons?! > > > On Jan 22, 9:54 pm, Michael Baldock <[email protected]> wrote: > > > David, > > > > Thanks for that tip, could be useful, I've tried it, and sadly nothing > > > works in production mode locally, not even the root page, all I get is > > > > Errno::ECONNREFUSED (Connection refused - connect(2)): > > > > I have no idea where that is coming, from! Think I'm going to have to > > > speak to the guy who actually built the site, before trying to > > > continue to maintain something I don't understand! > > > > On Jan 22, 9:38 pm, David Dollar <[email protected]> wrote: > > > > > You may be able to reproduce this locally by starting your app with > > RAILS_ENV=production > > > > > $ env RAILS_ENV=production rails server > > > > > On Sunday, January 22, 2012 at 4:24 PM, Michael Baldock wrote: > > > > > Hi, > > > > > > I'm trying to do something I think should be simple, and works fine > > on > > > > > my local machine, but crashes on heroku, I was hoping someone could > > > > > shed some light, as I'm totally baffled. > > > > > > I have a class called ScrapersController, with a standard set of > > views > > > > > and a model. In the same folder I have another class called > > > > > ScraperManager, that I use with delayed_job to go off and scrape > > > > > websites in the background. > > > > > > I create an instance of ScraperManager with > > > > > > @scraper_manager = ScraperManager.new > > > > > > I didn't think twice about writing this line, it works fine on my > > > > > local server, but on heroku it crashes. > > > > > > The error message I get sent is: > > > > > > /////////////// > > > > > Admin::Events is not missing constant ScraperManager! > > > > > .bundle/gems/ruby/1.8/gems/activesupport-3.0.3/lib/active_support/ > > > > > dependencies.rb:479:in `load_missing_constant' > > > > > /////////////// > > > > > > The folder is within Admin::Events. if it's NOT missing constant, why > > > > > is it breaking?? > > > > > > I've tried various ways of including the ScraperManager in the > > > > > ScraperController class, but cant work out how to do this > > > > > > require 'ScraperManager' - doesn't work > > > > > include Admin::Events::ScraperManager - doesn't work > > > > > > In most other languages it's easy to include a header file, but > > > > > apparently not in ruby! > > > > > > I've made an effort recently to try and emulate the heroku platform > > as > > > > > much as possible locally, precisely to avoid these inconsistencies, > > so > > > > > I'm using rvm to run ree-1.8.7 locally, which is the same as the > > stack > > > > > my app's on. > > > > > > I'm helping with this rails app up on heroku as a part-time / favour, > > > > > and every time I come back to the app after a couple of months , > > > > > things have started to fall apart! I don't know what it is about > > > > > ruby / rails, but nothing ever stays working for long!! > > > > > (sorry, frustrated rant over) > > > > > > Any help would be appreciated :-) > > > > > > -- > > > > > You received this message because you are subscribed to the Google > > Groups "Heroku" group. > > > > > To post to this group, send email to [email protected](mailto: > > [email protected]). > > > > > To unsubscribe from this group, send email to > > [email protected] (mailto: > > [email protected]). > > > > > For more options, visit this group athttp:// > > groups.google.com/group/heroku?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Heroku" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > >http://groups.google.com/group/heroku?hl=en. > > -- > Thanks, > -John -- You received this message because you are subscribed to the Google Groups "Heroku" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/heroku?hl=en.
