rack

What is ActiveSupport::Cache::Strategy::LocalCache used for?

本秂侑毒 提交于 2019-12-10 21:07:15
问题 In my production middleware stack in all environments I see this one-off instance: use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x7f38095d> I've experimented by removing everything I can think of related to caching, but I'm unable to figure out where it comes from. What is it? 回答1: In the abstract, it wraps another cache with an in-memory cache for the duration of a block, and then is cleared after the block. In practice I believe it is used in Rails/Rack to wrap whatever

You have already activated rack 1.6.0, but your Gemfile requires rack 1.6.4. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)

假如想象 提交于 2019-12-10 18:08:42
问题 I'm working with Elastic Beanstalk and I'm getting this error in my logs- You have already activated rack 1.6.0, but your Gemfile requires rack 1.6.4. Prepending bundle exec to your command may solve this. (Gem::LoadError) I've seen all related questions(Related Question) but nothing worked for me. When I do gem list | grep rack i get- rack (1.6.4) rack-test (0.6.3) That means I don't have rack(1.6.0) installed, which is confirmed when I do gem uninstall rack -v 1.6.0 it gives me- ERROR:

Mongoid 4 / MongoDB 2.4+ “Freezing” Issue

允我心安 提交于 2019-12-10 18:02:20
问题 I've had a strange issue since with maintaining a connection to mongodb using Mongoid. I thought this was originally due to upgrading to Rails 4.0+ (which required Mongoid/Moped to be updated), but I've also had this issue with other Rack-based apps (Sinatra and Grape to be specific). We updated our mongodb instance from 2.4 to 2.6 after the stable was released, but this issue was present on 2.4 as well. I wrote this up in an issue on Github (https://github.com/mongoid/moped/issues/274) but I

Rack URL Mapping

人盡茶涼 提交于 2019-12-10 16:47:30
问题 I am trying to write two kind of Rack routes. Rack allow us to write such routes like so: app = Rack::URLMap.new('/test' => SimpleAdapter.new, '/files' => Rack::File.new('.')) In my case, I would like to handle those routes: "/" or "index" "/*" in order to match any other routes So I had trying this: app = Rack::URLMap.new('/index' => SimpleAdapter.new, '/' => Rack::File.new('./public')) This works well, but... I don't know how to add '/' path (as alternative of '/index' path). The path '/*'

Sinatra doesn't show exceptions in log file

断了今生、忘了曾经 提交于 2019-12-10 11:26:07
问题 I'm coming from Rails to sinatra, and I have some problems using logging. I have a Sinatra app, that does it's logging like so: configure do Logger.class_eval { alias :write :'<<' } logger = Logger.new("log/#{settings.environment}.log") use Rack::CommonLogger, logger end All requests are logged properly, I see sth like 127.0.0.1 - - [25/May/2013 10:34:21] "GET / HTTP/1.1" 200 30 0.0021 127.0.0.1 - - [25/May/2013 10:34:22] "GET /favicon.ico HTTP/1.1" 404 18 0.0041 Inside the log files. But I

Rack Error — LoadError: cannot load such file

做~自己de王妃 提交于 2019-12-10 03:38:53
问题 Trying to go through the tekpub rack tutorial but run into this error. Boot Error Something went wrong while loading app.ru LoadError: cannot load such file -- haiku There is a file named haiku.rb in the same directory as the app I am trying to run but I get the above error while trying to run the program. Here is the code: class EnvironmentOutput def initialize(app=nil) @app = app end def call(env) out = "" unless(@app.nil?) response = @app.call(env)[2] out+=response end env.keys.each {|key|

Adding a custom middleware to Rails 4

风流意气都作罢 提交于 2019-12-10 01:40:06
问题 I have a Rails 4 sample project (Blog) and I have created a simple middleware called 'request_timer' in config/initializers/request_timer.rb #config/initializers/request_timer.rb class RequestTimer def initialize(app) @app = app end def call(env) start_time = Time.now status, headers, response = @app.call(env) stop_time = Time.now [status, headers, response.body] end end and I have added my middleware in config/application.rb in two ways 1 ) Adding as a constant #config/application.rb module

Heroku Cedar pure rack static site

谁说胖子不能爱 提交于 2019-12-09 19:30:56
问题 I've been trying to consolidate two tutorials for hosting static sites: Deploying Rack-based Apps for the cedar stack Static Sites with Ruby on Heroku/Bamboo Basically I want to be able to do what you do in the old bamboo tutorial on the cedar stack. I can get the cedar tutorial to work, but when I try modify it to serve files I get an error. I have had a look at the following post, but the github repo doesn't seem to be up any longer and I can't quite figure out where I've gone wrong. When I

Why is the rack env hash empty in Rails test environment?

…衆ロ難τιáo~ 提交于 2019-12-09 16:43:12
问题 In my Rails app, I'm accessing the env hash in one of my controller actions. Something along the lines of: def my_before_filter env['some.key'] = "Something or other" end This works great for my requirements. If I start my Rails app in test environment, and visit an action like: # /users in UsersController#index def index puts env.inspect end Then the content of the env hash is output to the console as expected. When I get this action from within an RSPec example, the output is an empty hash?

How to switch between different version of gem installed?

落花浮王杯 提交于 2019-12-09 14:33:03
问题 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 still use the activated rack with version 1.4.1 of the system. Bundle specifies which gem should be installed but doesn't ensure which gem will be activated . How could I activate certain version of rack ? 回答1: You can specify a version in