rack

Rack-Bug panels won't appear in my Rails app

I've installed Rack-Bug for my Rails app, but can't get the panels to appear. project: http://github.com/brynary/rack-bug additional instructions: http://wiki.github.com/brynary/rack-bug/security yet more instructions: http://stackoverflow.com/questions/1912983/rack-bug-installation-issue-server-does-not-start (the docs really suck for ...

Use Rack::CommonLogger in Sinatra

I have a small web-server that I wrote with Sinatra. I want to be able to log messages to a log file. I've read through http://www.sinatrarb.com/api/index.html and www.sinatrarb.com/intro.html, and I see that Rack has something called Rack::CommonLogger, but I can't find any examples of how it can be accessed and used to log messages. ...

What is rack middleware?

Hi, What is rack middleware? Thanks. ...

How to serve static files via Rack?

Hi, I am currently developing a Rack-based application and want to redirect all file requests(e.g. filename.filetype) to a specified folder. Rack::Static only supports file requests for a special folder(e.g. "/media"). Do I have to write an own Rack middleware or does a out-of-the-box solution exist? Best regards ...

Anyone using JRuby-Rack with Rails 3?

Is anyone else out there running Rails 3 and JRuby-Rack, or Jetty and Rails 3? Any trick to it? I'm going insane with some debugging, and at this point I just want to know that it's possible. ...

RubyGem version error: rack(1.0.0 not ~> 1.0.1)

I was working on a rails project on my laptop and pushing code to github. Now I cloned the project on my desktop. when running: rake db:migrate I get the following error: rake aborted! RubyGem version error: rack(1.0.0 not ~> 1.0.1) (See full trace by running task with --trace) Before this error I had to run the following comma...

Problem with require rack/openid in Rails 3 [native require work properly]

I install plugin open_id_authentication and have this error: /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:167:in `require': no such file to load -- rack/openid (LoadError) when I try to start rails server Actually, rack-openid installed in my system and i can load it from irb: irb(main):00...

Multiple rack apps on nginx + passenger, one as root, the other not...config help

So I've got two apps I want to run on a server. One app I would like to be the "default" app--that is, all URLs should be sent this app by default, except for a certain path, lets call it /foo: http://mydomain.com/ -> app1 http://mydomain.com/apples -> app1 http://mydomain.com/foo -> app2 My two rack apps are installed lik...

Where does RACK log to ?

I am running a sinatra app through RACK. To which file does the activity get logged ? Also how can I set the log file path ? ...

Can't find out where my Ruby 1.9 string encoding is getting messed up.

Somewhere along the line from the DB to the application, this: sauté is getting turned into this: sauté I'm using Ramaze + Rack + MySQL. I've got a force_encoding plugin set up, so the encoding on the string is UTF-8. If I view the record in the database shell, it's looks fine. The default charset on the table is utf8, and the fie...

Why is Rack::Cache not hitting cache when etag matches?

Starting with no cache on server or client FIRST REQUEST GET /post/1 HTTP/1.1 HTTP/1.1 200 OK Date: Fri, 05 Mar 2010 09:05:46 GMT Last-Modified: Thu, 04 Mar 2010 21:00:08 GMT X-Rack-Cache: miss Etag: "c226165d5817af7c91592dab0bc0ac63" Cache-Control: max-age=3600, public The Cache is missed and Rails gets hit and queries the database...

Is it possible to call rails model methods from rack middelware?

def inside_rack_middelware MyModel.update_attributes(:ip => request.ip) redirect somewhere else end is that possible? ...

Testing Rails Metal/Rack with RSpec?

Say I have a Metal class named Preview. How do I test it with RSpec? When I try: require 'spec_helper' describe Preview do it "should return the posted content" do post "/preview", :content => "*title*" response.body.should == "*title*" end end I get: undefined method `post' for #<ActiveSupport::TestCase::Subclass_1:0...

Rack::Test not able to find web app cookie

While testing a Sinatra app with Cucumber, Rack::Test was not able to find the cookie that my app created, even though I could clearly see that it was in the Rack::Test::CookieJar object by dumping it with "p". ...

Rack throwing an error when trying to serve a static file.

use Rack::Static, :urls => ['/stylesheets', '/images'], :root => 'public' run proc { |env| [200, { 'Content-Type' => 'text/html', 'Cache-Control' => 'public, max-age=86400' }, File.open('public/index.html')] } I get private method `open' called for Rack::File:Class when I rackup. Really can't see where the problem is. Running rack 1....

Rack middleware deadlock

I include this simple Rack Middleware in a Rails application: class Hello def initialize(app) @app = app end def call(env) [200, {"Content-Type" => "text/html"}, "Hello"] end end Plug it in inside environment.rb: ... Dir.glob("#{RAILS_ROOT}/lib/rack_middleware/*.rb").each do |file| require file end Rails::Initial...

Is it possible to refuse rack requests based on request method.

I am looking to refuse connections from inside a rack app. Now I currently do this in a middleware (lowest level) by simply checking: env['REQUEST_METHOD'] and if it one I don't desire I pass back either a 301 or a 404 etc... However I was wondering if there was a lower level mechanism for doing the same thing within rack itself? I kn...

Sinatra, JavaScript Cross-Domain Requests JSON

I run a REST-API build on top of Sinatra. Now I want to write a jQuery Script that fetches data from the API. Sinatra is told to response with JSON before do content_type :json end A simple Route looks like get '/posts' do Post.find.to_json end My jQuery script is a simple ajax-call $.ajax({ type: 'get', url: 'http://api....

Can you let users upload Sinatra apps and run them inside Rails as middleware?

I want to let users write small custom apps (think themes or plugins on Wordpress) and upload/run them on my site. I'm thinking about using Sinatra apps for this since it would give the users a lot of flexibility, and then running them as middleware inside my rails app. But I can't figure out the security implications of this. I tried...

Showing response time in a rails app.

I want to display a This page took x seconds widget at the bottom of every page in my rails application. I would like x to reflect the approximate amount of time the request spent on my server. What is a good way of doing this? Edit: My production server is on phusion passenger and development environment on mongerel. Would love to ha...