Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
freeb0rn
Jan 22, 2005

shopvac4christ posted:

In C# I have the '??' operator, which when used like 'a ?? b', returns a unless it is a null object, in which case it returns b. Is there anything like that in Ruby?

EDIT: Wow, ignore that. I was retarded. My original question still stands.
The or operator (||) in Ruby can work like this.

Adbot
ADBOT LOVES YOU

freeb0rn
Jan 22, 2005

Hop Pocket posted:

I've been using my free time to code some RoR apps, and it's going fairly well. I have a dreamhost account that uses FastCGI to run the rails apps. When I deploy using Capistrano, there's a 10-15 second delay which is I'm assuming the FastCGI processes restarting because of the application change. However, if I check the deployed site after an hour or two of inactivity, I get the same delay.

In both cases, the site runs snappy after the first hit to the webapp. Is there a way to force the FastCGI processes to stay running (assuming that this is the cause of the delay)?

That is the cause of the delay and the solution is a script that loads the site every X minutes.

From the Dreamhost wiki:
http://wiki.dreamhost.com/Ruby_on_Rails#Switching_to_FCGI_with_Dreamhost
See the section "Preventing timeouts using curl and cron"

freeb0rn fucked around with this message at 20:41 on Nov 10, 2007

freeb0rn
Jan 22, 2005
Does anyone know if I can figure out within an action (in a controller) if the action has been called "remotely" (all AJAX-like) or not? Apart from sending some sort of special parameter when you update remotely and figuring it out on your own, that is.

EDIT:
Apparently this is done by inspecting the Accept header and using respond_to, which is what I thought but hadn't figured out how, exactly.
This little excerpt I found sheds some more light on the situation:

quote:

If an old browser submits this form, we'll have it done through a plain old POST, which the browser sends along with a header like "Accept: */*". That means "I don't care what kind of response you give me, just give me something". Since the browser doesn't care, we'll decide what to do on the order of the type declarations. The first is type.html, so that's what we'll perform, which in this case simply instructs the browser to go back to the index.

If an Ajax-capable browser submits this form, Prototype will intercept the submission and turn it into an Ajax call. This call will be send along with "Accept: text/javascript, text/html, application/xml, text/xml */*", which specifies a preference order where Javascript is first, if not available, then HTML, if not, then XML, and finally it'll accept whatever if none of the preferred forms are available.
http://ajaxian.com/archives/using-the-http-accept-header-for-ajax

freeb0rn fucked around with this message at 06:54 on Feb 28, 2008

freeb0rn
Jan 22, 2005
Yeah I'm using that second approach.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply