rack

JRuby / Rack deployment

I know this is pretty exotic, but I want to deploy a Ruby web application (not Rails, but Rack based, so it plugs into most Ruby servers just fine) using JRuby. Google and friends give me a few success stories, but mostly rails related and if not, no details on the deployment are provided. The framework I'm using is Ramaze, if it matters...

Do I need to leave gaps in a standard server rack?

We have a 42U rack which is getting a load of new 1U and 2U servers real soon. One of the guys here reckons that you need to leave a gap between the servers (of 1U) to aid cooling. Question is, do you? When looking around the datacenter, no-one else seems to be, and it also diminishes how much we can fit in. We're using Dell 1850 and...

Multipart response in Ruby/Rack

I want my server to send a multipart response (multipart/x-mixed-replace). I'd prefer some kind of solution using the Sinatra framework or a generic Rack app, but any example in ruby would be nice. Here's the equivalent of what I'm trying to do, in PHP: <?php header('Content-type: multipart/x-mixed-replace;boundary="rn9012"'); prin...

Why do I get an error on the first request after restarting a Sinatra app with Rack and Phusion Passenger?

After I touch tmp/restart.txt and my app restarts, the first request throws an error, usually something about not finding Haml::Engine or some other gem. The second and subsequent requests all work fine. I was having this problem on Dreamhost which was running Rack 0.4.1 and Sinatra 0.3.3 but after moving to my own host and running a ne...

What's the difference between Rack and Rails Metal (Ruby)?

I don't get it! Rack: http://rack.rubyforge.org/ Rails Metal: http://weblog.rubyonrails.org/2008/12/17/introducing-rails-metal I read the two articles and my eyes got blurry. How do the two components relate? Examples would be great? ...

What's the difference between Rack and Passenger?

I'm trying to deploy a Sinatra app to Dreamhost and it says the following: Since DH supports Passenger, which in turn supports Rack-based ruby applications, DH does indeed support Sinatra. I'm having difficulty parsing that statement - what's the difference between Rack and Passenger (and why is Sinatra "Rack-based")? ...

How do I access the Rack environment from within Rails?

I have a Rack application that looks like this: class Foo def initialize(app) @app = app end def call(env) env["hello"] = "world" @app.call(env) end end After hooking my Rack application into Rails, how do I get access to env["hello"] from within Rails? Update: Thanks to Gaius for the answer. Rack and Rails let y...

How do I use a Rack middleware only for certain paths?

I'd like to have MyMiddleware run in my Rack app, but only for certain paths. I was hoping to use Rack::Builder or at least Rack::URLMap, but I can't quite figure out how. This is what I thought would work, but doesn't: # in my rackup file or Rails environment.rb: map '/foo' do use MyMiddleware, { :some => 'options' } end Or, bett...

Running Ruby scripts under JRuby/Rack as if they were CGIs

Is there a way to map *.rb files to be executed under JRuby with the output being sent out to the browser like a CGI? Basically I'm looking for a JRuby CGI servlet. Ideally, I'd like to define a JRuby servlet in web.xml and then be able to put *.rb files in WEB-INF/ruby and be able to call them via http://servername/contextname/rubypro...

Running gem server in passenger

I'm running a few rails/rake apps in Apache/passenger and I want to add the documentation app served by gem server to these apps, so I can easily give it a special (sub)domain, like docs.example.org, so it's easily available for all members of our team and nobody has to start the server himself or remember port numbers (like 8808, the de...

what is the impact of rails 2.3's rack support?

Does it make any difference in terms of developing Rails apps now that it uses rack to talk to web servers? Should we do anything differently to take advantage of it? Is it just cleaner or does it have any performance improvement over the cgi implementation? ...

How do I get the response returned from Rack in a Cucumber step?

I have a Cucumber step for my Rails application: Then /^I should be redirected to the sign in page$/ do assert_equal 302, @response.status end But that @response object is the one returned by my Controller, and it's the Rack middleware that sets the status to what I expect it to be. How can I get at the response as returned from th...

rack-jsonp not working for simple requests but works for .js calls in Rails 2.3

I am using Rails 2.3 and I decided to provide support for JSONP. Created a brand new application. Then ran script/generate scaffold User name:string This is my entire environment.rb RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION require File.join(File.dirname(__FILE__), 'boot') require 'rack/contrib' Rails::Initializer.r...

Ruby On Rails is itself a Rack app?

So I deduced from Rack documentation, but maybe I am wrong... ...

User sign-up with email verification, and authentication in Ruby

I'm trying to make a web app in Sinatra, and I was wondering if there was a good solution for user sign-up with email verification, as well as authentication - perhaps as rack middleware? OpenID support would be nice to have too. I suppose I can roll my own, but I didn't want to reinvent the wheel. If I have to do so, can anyone point m...

set method to PUT in rails XML requests

if I do this: curl -X POST -H 'Content-type: application/xml' -d '<person>...</person>' 'http://0.0.0.0:3000/people/12?_method=PUT' I get "Only get, put, and delete requests are allowed." Why? Rails 2.3.2 ...

Ruby, Rack and headers such as "Accept-Ranges" or "X-Content-Duration"

Does anyone have an example of how to add additional headers to the Thin Ruby server? Specifically, I need to add either "Accept-Ranges" or "X-Content-Duration" for media based files served, ogg audio and video mostly, served via the new HTML5 media elements. If someone has a fix for this, or a link to a really good tutorial about Rack,...

What is meant by the Passenger-enabled Nginx error 'rack_env directive is duplicate'?

When we try to start Nginx, we see this error that prevents Nginx from starting. The error exactly is: "rack_env" directive is duplicate We have set rails_env and rack_env... does this conflict in some way? Any ideas what is meant by it? We can't find any meaningful documentation in the Nginx Passenger User guide nor in the source nor...

Rack fails with Rails when I try to upload file (using paper clip) on Ruby 1.9

Hi, I have a Ruby on Rails application I'm using Ruby 1.9 and Rails 2.3.4 and I want users to upload videos so I installed Paperclip gem but I'm getting this error from Rack. The fact that it says it's "invalid byte sequence" makes me suspect that it's from Ruby 1.9. any ideas? Thanks, Tam Rendering posts/new Rendered posts/_form (...

How to configure VirtualHost for a Sinatra App with Passenger?

Hey experts, i run a rails app on passenger and it all works like it should. Now i want to add an sinatra app to run as rack application with passenger, but i always get a routing error. My VirtualHosts File looks like: NameVirtualHost *:80 <VirtualHost *:80> ServerName www.domain1.com DocumentRoot /home/user1/vhosts/project1/pub...