actiondispatch

how does a middleware get deleted?

余生颓废 提交于 2019-12-22 09:06:54
问题 rack-timeout is included in the Gemfile, but we only want it as middleware on production. Thus in an initializer, we have: config.middleware.delete Rack::Timeout Inspecting before and after this line shows rack-timeout removed from the array. Regardless, requests are still timing out, and a quick 'puts' in the gem shows that it is indeed the culprit. Is this because the middleware stack has already been built before delete is called? Or is the stack read in every request? If that's the case,

How do you use ActionDispatch::Routing::RouteSet recognize_path?

拜拜、爱过 提交于 2019-12-22 08:01:34
问题 How do you use ActionDispatch::Routing::RouteSet recognize_path? I want to get the current path for the view. I tried <div id="<%= ActionDispatch::Routing::RouteSet::recognize_path %>"> but got "undefined method `recognize_path' for ActionDispatch::Routing::RouteSet:Class". Thanks! 回答1: Path of the Request: request.path Path of the file: __FILE__ 回答2: You can do this Rails.application.routes.recognize_path "/your/path" It works in rails 3.1.0.rc4 来源: https://stackoverflow.com/questions

Rails 5.1: “unknown firstpos: NilClass” - Issue reloading application

别说谁变了你拦得住时间么 提交于 2019-12-20 09:26:57
问题 Following an upgrade from Rails 5.0 to 5.1 I'm getting this error anytime the app reloads, either from code changes during rails server or if I call reload! from the console. 🌶 13:53$ rc Loading development environment (Rails 5.1.1) 2.3.1 :001 > reload! Reloading... ArgumentError: unknown firstpos: NilClass from (irb):1 2.3.1 :002 > https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/journey/gtg/builder.rb Application Trace is empty, here's the Framework Trace:

Rails: ParameterFilter::compiled_filter tries to dup symbol

笑着哭i 提交于 2019-12-19 08:12:06
问题 I'm running rails3 with rails exception-notifier gem. When an exception occurs, and an email should be sent, I'm getting an exception from the ParameterFilter class. I've found the problem in the rails source, and am not sure the best way to proceed. The problem occurs in ActionDispatch::Http::ParameterFilter. In the compiled_filter method, an error occurs on line 38: key = key.dup when key is a symbol, because symbols are not duplicable. Here is the source: def compiled_filter ... elsif

Rails 4.2 server; private and public ip not working

微笑、不失礼 提交于 2019-12-18 19:24:48
问题 I recently updated my rails 4.1.8 to 4.2 I'm not able to access rails app using private ip 192.168.1.x:3000 and also with my public-ip address . Rails app is working with lvh.me:3000 , 0.0.0.0:3000 , localhost:3000 and 127.0.0.1:3000 . But it looks all the the address are pointing to 127.0.0.1:3000 in my server log rails-issue. It was working fine in 4.1 I tried adding following in environments/development.rb , but nothing changed. TRUSTED_PROXIES = %r{ ^127\.0\.0\.1$ | # localhost ^(10 | #

Rail 5 swap ActionDispatch::Reloader with a custom reloader

懵懂的女人 提交于 2019-12-11 11:49:46
问题 We have a use case for mounting a mock engine to process sessions when developing locally in which a custom session middleware calls the mock engine via Net::http request when a request comes through. When there is code change, the reloader is triggered and here calls the ActiveSupport::Dependencies to start unloading. Then the request is pass down to our custom session middleware and the http request is fired. However since the http request calls to a mountable engine, it goes thought the

Rails, how do you access the raw request data at the absolute lowest level?

别等时光非礼了梦想. 提交于 2019-12-10 04:10:03
问题 When is the Rails request object available at the earliest time during the request lifecycle? Essentially, when is the request first available as a request object, and in which object? ActionDispatch ? Can you access request parameters from Tester::Application ? If so, how? If not, what about using the environment? When is that information set? 回答1: The Rack webserver creates the request object and then ActionDispatch inherits from it. So essentially, you'd be able to access the Rack::Request

Rails: Filter sensitive data in JSON parameter from logs

佐手、 提交于 2019-12-09 05:42:36
问题 I am running Rails 3 and trying to filter sensitive information out of our logs which are JSON blobs that are passed as post parameters. For example, user creation might take a post param called user with a string value that is a JSON object. One of the keys in the JSON object is password and we want to filter this out of our logs. The best way I found to do this was to add a block to our filter_params, like so: keys_to_filter = ['password', 'password_confirmation'] config.filter_parameters <

Test for HTTP status code in some RSpec rails request exampes, but for raised exception in others

喜欢而已 提交于 2019-12-08 14:37:54
问题 In a Rails 4.2.0 application tested with rspec-rails , I provide a JSON web API with a REST-like resource with a mandatory attribute mand_attr . I'd like to test that this API answers with HTTP code 400 ( BAD REQUEST ) when that attribute is missing from a POST request. (See second example blow.) My controller tries to cause this HTTP code by throwing an ActionController::ParameterMissing , as illustrated by the first RSpec example below. In other RSpec examples, I want raised exceptions to

How do you use ActionDispatch::Routing::RouteSet recognize_path?

谁说我不能喝 提交于 2019-12-05 17:26:22
How do you use ActionDispatch::Routing::RouteSet recognize_path? I want to get the current path for the view. I tried <div id="<%= ActionDispatch::Routing::RouteSet::recognize_path %>"> but got "undefined method `recognize_path' for ActionDispatch::Routing::RouteSet:Class". Thanks! Path of the Request: request.path Path of the file: __FILE__ You can do this Rails.application.routes.recognize_path "/your/path" It works in rails 3.1.0.rc4 来源: https://stackoverflow.com/questions/6459403/how-do-you-use-actiondispatchroutingrouteset-recognize-path