Questions tagged [rack]

Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.

Rack is a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.

Useful Links

1617 questions
15
votes
2 answers

How to use cookies in a Rack middleware?

I am using Ruby on Rails 3 and I would like to use the cookies.signed method in a Rack middleware. I need that because I would like to authenticate a user directly in the middleware than of using a before_filter in the application_controller.rb…
user502052
  • 14,803
  • 30
  • 109
  • 188
15
votes
3 answers

What is rack? can I use it build web apps with Ruby?

ruby newbie alert! (hey that rhymes :)) I have read the official definition but still come up empty handed. What exactly is it when they say middleware? Is the purpose using ruby with https? the smallish tutorial at patnaik's blog makes things…
Amit Erandole
  • 11,995
  • 23
  • 65
  • 103
15
votes
2 answers

Is it possible to use rescue with a conditional?

Consider a Rack app. I only want to handle the error if we are not running a test: begin do_something if ENV[ 'RACK_ENV' ] != 'test' rescue => error handle_error error end end end This generates syntax error, unexpected…
B Seven
  • 44,484
  • 66
  • 240
  • 385
15
votes
1 answer

Using `Rack::Session::Pool` over `Rack::Session::Cookie`

What are the different use cases of Rack::Session::Pool and Rack::Session::Cookie? As far as I understand (correct me if I'm wrong): Cookie stores all the session key:value pairs directly within the cookie (marshalled) Pool only stores an id in…
pje
  • 21,801
  • 10
  • 54
  • 70
14
votes
2 answers

How does Rails serve static content out of public?

How much ruby code deals with serving static content out of public? Does it pass through the rails app at all? Does it use Rack::Static?
John Bachir
  • 22,495
  • 29
  • 154
  • 227
14
votes
6 answers

Rails 3.1 Force Regular HTTP

Previously, I had been using ssl_requirement to give us fine grained control over which pages were served over ssl and which were served over plain http. According to the ssl_requirement's own wiki, it has been superseded by rails 3.1's Force SSL.…
ghempton
  • 7,777
  • 7
  • 48
  • 53
14
votes
2 answers

Selectively allow some urls through Rack::Auth::Basic

I've set up a blog that I'd like to be minimally secured (i.e., I just want to keep out random people I don't know, I'm not trying to implement NSA-like security measures). I'm using toto with Rack::Auth::Basic to "secure" the site. I'd like to let…
guidoism
  • 7,820
  • 8
  • 41
  • 59
14
votes
3 answers

Very slow: ActiveRecord::QueryCache#call

I have an app on heroku, running on Puma: workers 2 threads_count 3 pool 5 It looks like some requests get stuck in the middleware, and it makes the app very slow (VERY!). I have seen other people threads about this problem but no solution so…
user3029400
  • 387
  • 1
  • 5
  • 13
14
votes
3 answers

Set Rack session cookie expiration programmatically

I'm using Rack to try to implement "Remember Me" functionality in my Sinatra app. I'm able to set the session cookie to expire when the session ends or in X seconds time but I'd like to do both. For example, if a user has clicked "remember me" then…
Gerard
  • 4,818
  • 5
  • 51
  • 80
14
votes
3 answers

Rack middleware "trapping" stack trace

I have a piece of Rack middleware that loads a tenant, via subdomain, and applies some default settings. The middleware, while not pretty, does it's job fine enough. However, when an exception is thrown within the app the middleware "traps" the full…
bennick
  • 1,879
  • 15
  • 21
14
votes
4 answers

How can I test helpers blocks in Sinatra, using Rspec?

I'm writing a sinatra app and testing it with rspec and rack/test (as described on sinatrarb.com). It's been great so far, until I moved some rather procedural code from my domain objects to sinatra helpers. Since then, I've been trying to figure…
julien
  • 1,879
  • 2
  • 20
  • 29
14
votes
3 answers

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 ?
Prakash Raman
  • 13,319
  • 27
  • 82
  • 132
14
votes
2 answers

Calling a Sinatra app instance method from TestCase

I have an util method into a Sinatra application and I would like to tested from my TestCase. The problem is that I don't know how to invoke it, if I just use app.util_method I have the error NameError: undefined local variable or method…
fguillen
  • 36,125
  • 23
  • 149
  • 210
14
votes
1 answer

rack-mini-profiler is showing profiling static files

I'm using rack-mini-profiler after watching it's railscast (http://railscasts.com/episodes/368-miniprofiler). I added it to my Gemfile: gem 'rack-mini-profiler' Installed it using bundler and started my dev environment using "rails s". The…
razenha
  • 7,660
  • 6
  • 37
  • 53
13
votes
2 answers

How to switch between different version of gem installed?

I have three version of rack installed on local machine (rack (1.4.1, 1.3.6, 1.3.5)). For some gem (such as Cucumber), it requires a lower version of rack to be activated? I have tried with bundle but there is no good. When executed, cucumber will…
steveyang
  • 9,178
  • 8
  • 54
  • 80