Forum: Ruby on Rails RE: Newbie Question about Custom Classes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hogan, Brian P. (Guest)
on 2006-03-20 22:07
(Received via mailing list)
Yes you would run two WEBrick servers on different ports.  I guess I've
never run into a situation on my local machine where that's been an
issue; if I need that, then I deploy to staging.

Whatever works for you!

As for your caching... I'm baffled. Perhaps you have the environment set
to production in the environment file?
Brent J. (Guest)
on 2006-03-20 23:10
(Received via mailing list)
On 3/20/06, Hogan, Brian P. <removed_email_address@domain.invalid> wrote:
> Yes you would run two WEBrick servers on different ports.  I guess I've
> never run into a situation on my local machine where that's been an
> issue; if I need that, then I deploy to staging.
>
> Whatever works for you!

Yeah, using separate ports will be an acceptable solution.  If there's
some weirdness when it moves from development to staging then I'll
deal with it then.  I think it'll be fine though.

> As for your caching... I'm baffled. Perhaps you have the environment set
> to production in the environment file?

The only thing uncommented out in environment.rb is:

require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
end

That's it.  And here is what's uncommented in the environment files:

development.rb
----------------
config.cache_classes     = false
config.whiny_nils        = true
config.breakpoint_server = true
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching             = false
config.action_mailer.raise_delivery_errors = false

test.rb
--------
(all the same as above except the last line)
config.action_mailer.delivery_method = :test

production.rb
---------------
config.cache_classes = false
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching             = false

And that's it.  But it still insists on caching the class when I
change it.  Here's the kicker, I can change the controller all day
long and it doesn't cache it.  So, for example, my "blah" method just
returns a static string, I then set @page_title to what it returns
before it's handed off to my layout, partials and view.  If I change
what article.rb returns it doesn't change (appears to be cached), BUT
if I change the controller and just append "BRENT" to what it returns,
THAT change appears but the text that prepends that is still the old
cached string from the blah call.

It's driving me nuts.  I'm definitely NOT going to restart the server
after every little change to a class.

Thanks,

- Brent
Brent J. (Guest)
on 2006-03-20 23:32
(Received via mailing list)
Alright I just ran into something that's exactly what I'm talking
about when I say a difference in environment by not using the same
webserver.

I switched to WEBrick and a piece of my code stopped working.  When I
make this call:

file = File.new("public/news.xml")

It works fine using WEBrick, because the rails root is the current
working directory.  HOWEVER, under Apache this is not the case.  Rails
REPORTS that the root is the cwd, even in the file not found error,
but I went crazy trying to figure out why it couldn't find it because
I knew it was there.

Turns out when running under Apache, the cwd is in a subdirectory of
the root.  If I had to guess I'd say the cwd was the "config"
directory and not the actual rails root.  So my code was set to look
for it in "../public/news.xml" and that worked perfectly fine.  As
soon as I switch to WEBrick, bang, error.  Anyone else use Apache and
notice this?

- Brent
This topic is locked and can not be replied to.