rack

Ruby web pages without any framework from scratch [closed]

。_饼干妹妹 提交于 2019-12-24 04:25:13
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I'm trying to learn ruby for web from scratch. I know PHP and I'm new in ruby. I don't want to use any framework at beginning. Trying

Getting thin to read configured user environment

痞子三分冷 提交于 2019-12-24 00:27:23
问题 I'm starting thin with a parameter set like the following under ubuntu chdir: /var/www/myuser/current rackup: /var/www/myuser/current/config.ru environment: production address: 0.0.0.0 port: 3000 timeout: 30 log: log/thin.log pid: tmp/pids/thin.pid max_conns: 1024 max_persistent_conns: 512 require: [] wait: 30 servers: 3 daemonize: true user: myuser group: myuser And I want to define a set of environment variables for "myuser" so they can be accessible in the rack application I'm deploying in

Can the Rails logger be accessed from within a Rack middleware?

白昼怎懂夜的黑 提交于 2019-12-23 10:02:54
问题 I'd like to log things from within a middleware that I'm putting into a Rails app, using the app's existing logger. Is there a standard way to do this? Two possibilities that come to mind: the logger is directly accessible in the rack environment the loger can be accessed at app boot time and assigned to the middleware Searching for solutions involving either of these doesn't come up with much. I haven't fully thought through/experimented to see if the order of operations allows either to be

Random slow Rack::MethodOverride#call on rails app on Heroku

萝らか妹 提交于 2019-12-23 07:03:23
问题 Environment: Ruby: 2.1.2 Rails: 4.1.4 Heroku In our rails app hosted on Heroku, there are times that requests take a long time to execute. It is just 1% of times or less, but we cannot figure out what it is happening. We have newrelic agent installed and it says that it is not request-queuing , it is the transaction itself who takes all that time to execute. However, transaction trace shows this: (this same request most of the times takes only 100ms to be executed) As far as I can tell, the

Trigger basic HTTP auth from within middleware

核能气质少年 提交于 2019-12-23 03:50:18
问题 I have created a custom middleware for rails which will intercept all requests and make sure it's coming from an authorized IP, otherwise it should prompt for a basic http auth user/name password. This is currently what it looks like: require 'net/http' class AuthorizeEnvironment def initialize(app) @app = app end def call(env) if AppConstants.approved_doximity_ips.include?(env["REMOTE_ADDR"]) @app.call(env) elsif authorized?(env) @app.call(env) else [403, {"Content-Type" => "text/html"}, [

Rails serving large files

杀马特。学长 韩版系。学妹 提交于 2019-12-22 22:51:52
问题 I'm developing an application serving large videos only to logged users. To keep these videos private i put them in a private folder inside Rails project and let Rails serve them, instead of using the public folder and excluding requests from apache (to avoid direct linking to them). My action in the controller looks like this: def video respond_to do |format| format.mp4{ send_file File.join([Rails.root, "private/videos", @lesson.link_video1 + ".mp4"]), :disposition => :inline, :stream =>

how to change default behaviour of rack offline

跟風遠走 提交于 2019-12-22 17:06:32
问题 I am trying to use rack offline in rials to make my webpage available offline. By default rack offline takes all files from the public folder into the cache manifest. In which file should I make changes so that it will take the add the file that I want into the cache manifest. I want to include the file in my views folder. 回答1: You need to add it to your routes.rb file. Here is my routes.rb file with a customized manifest. This will give you the index and the new routes as well as all of the

Sinatra: three logs

陌路散爱 提交于 2019-12-22 15:33:33
问题 I'm using a very simple Sinatra app that works well. However, every log message is repeated three times. I can bring that down to two by disabling the Sinatra logging with disable :logging but I still have two. The messages are slightly different, so I gather they are coming from Rack and somewhere else in the stack too. How do I completely disable logging of successful web requests? 回答1: Rack is adding own logging as a middleware try to run rackup -E none This removes one log entry. The

Gitlab Rack Attack Insallation

亡梦爱人 提交于 2019-12-22 10:38:52
问题 I was installing gitlab and followed all the instructions of the installation guide of Gitlab. Everything works fine but then at Step "Initialize Database and Activate Advanced Features" it failed! https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md I got this error Message. rake aborted! uninitialized constant Rack::Attack /home/git/gitlab/config/application.rb:82:in `<class:Application>' /home/git/gitlab/config/application.rb:13:in `<module:Gitlab>' /home/git/gitlab

Rails + Rspec + Rack + Session testing

你。 提交于 2019-12-22 09:48:03
问题 Gemfile file: 'rack', '~> 1.6.0' I am having little trouble in passing the session variables from rspec tests to the Rack middleware. I have gone through many articles on internet but there is no solution which can help me to understand. So basically i want to be able to do this in my middleware class req = Rack::Request.new(env) req.session[:token] But currently req.session[:token] comes as empty from my rspec. How can I set session in my R spec class so that i can test different scenario's