rack

git, Heroku: pre-receive hook declined

吃可爱长大的小学妹 提交于 2019-11-27 22:46:54
I am in the process of setting up a git repository and attempting to link it to Heroku. When I run the command git push heroku master I receive Counting objects: 7, done. Delta compression using up to 2 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (7/7), 714 bytes, done. Total 7 (delta 1), reused 0 (delta 0) -----> Heroku receiving push ! Heroku push rejected due to an unrecognized error. ! We've been notified, see http://support.heroku.com if the problem persists. To git@heroku.com:morning-stream-3712.git ! [remote rejected] master -> master (pre-receive hook declined

Disable Sprockets asset caching in development

穿精又带淫゛_ 提交于 2019-11-27 21:38:06
问题 I'm using Rails 3.2.13 and the Rails Asset Pipeline. I want to use the Asset Pipeline so I can use SASS and CoffeeScript and ERB for my assets and have the Pipeline automatically compile them, so I cannot turn off the pipeline in development. I am not precompiling assets in development ever and there is not even a public/assets/ directory. However, when I make changes to an included file, such as to a _partial.html.erb file that is included (rendered) in a layout.html.erb file, without

Bypassing rack version error using Rails 2.3.5

落爺英雄遲暮 提交于 2019-11-27 21:36:41
I'm currently on Dreamhost attempting to run a Rails 2.3.5 app. Here is the situation, Dreamhost's servers have Rails 2.2.2 installed. Of course, I can't update a shared host's rails version, so I froze my Rails in vendor. Rails 2.3.5 requires the rack v1.0.1 gem. Dreamhost uses the rack v1.0.0 gem. So when I try to define: config.gem "rack", :version => "1.0.1" I get: can't activate rack (~> 1.0.1, runtime) for [], already activated rack-1.0.0 for [] So what I really need to do is bypass my app's request to use 1.0.1, and use Dreamhost's 1.0.0. Does anyone know how to configure this? Is it

How to serve static files via Rack?

三世轮回 提交于 2019-11-27 17:27:12
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 To redirect every request to a particular path, use Rack::File (for some reason this class is absent in recent documentation, but it is still part of the latest Rack): run Rack::File.new("/my/path") To redirect every request, and add an HTML index of all files in the target dir, use Rack:

How to parse JSON request body in Sinatra just once and expose it to all routes?

亡梦爱人 提交于 2019-11-27 17:09:16
问题 I am writing an API and it receives a JSON payload as the request body. To get at it currently, I am doing something like this: post '/doSomething' do request.body.rewind request_payload = JSON.parse request.body.read #do something with request_payload body request_payload['someKey'] end What's a good way to abstract this away so that I don't need to do it for each route? Some of my routes are more complicated than this, and as a result the request.body would get reread and reparsed several

How do I set/get session vars in a Rack app?

本小妞迷上赌 提交于 2019-11-27 15:48:11
问题 use Rack::Session::Pool ... session[:msg]="Hello Rack" EDIT: The word session doesn't seem to resolve. I included the Session pool middleware in my config.ru, and try to set a variable in an ERB file (I'm using Ruby Serve) and it complains "undefined local variable or method `session'" Thanks! 回答1: session is a method that is part of some web frameworks, for example Sinatra and Rails both have session methods. Plain rack applications don’t have a session method, unless you add one yourself.

Using Cookies with Rack::Test

北慕城南 提交于 2019-11-27 14:48:29
问题 I'm trying to write RSpec tests for my Sinatra application using Rack::Test. I can't understand how I can use cookies. For example if my application set cookies (not via :session) how can I check whether that cookie is properly set? Also, how can I send requests with that cookie? 回答1: Rack::Test keeps a cookie jar that persists over requests. You can access it with rack_mock_session.cookies . Let's say you have a handler like this: get '/cookie/set' do response.set_cookie "foo", :value =>

Rails 3.1 Force Regular HTTP

元气小坏坏 提交于 2019-11-27 13:19:34
问题 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. However this does not seem to be the case. Force SSL doesn't seem to expose an option to go in the opposite direction, there is no way to force a page to sent via regular http. What is the correct Rails 3.1 way to force a page to be displayed in

How to determine if Rails is running from CLI, console or as server?

倖福魔咒の 提交于 2019-11-27 12:48:52
问题 I have a middleware for announcing my application on the local network app using Bonjour, but it's also announcing the service when Rails is invoked from rake or through the console. I'd like to exclude these cases, and only use the Bonjour middleware when Rails is running as a server. The middleware configuration accepts a proc to exclude middlewares under certain conditions using a proc : config.middleware.insert_before ActionDispatch::Static, Rack::SSL, :exclude => proc { |env| env['HTTPS'

Streaming data from Sinatra/Rack application

旧街凉风 提交于 2019-11-27 11:56:53
I am trying to stream textual data (XML/JSON) from a Ruby (1.9.1p378) Sinatra (1.0) Rack (1.2.1) application. The suggested solutions (e.g. Is there a way to flush html to the wire in Sinatra ) do not seem to work - the server just blocks when I yield elements of some infinite stream (e.g. from %w(foo bar).cycle ). I tried webrick and thin as servers. Any suggestions on getting this done? Should I use http://sinatra.rubyforge.org/api/classes/Sinatra/Streaming.html and if so how would I use it in my application? Neither Webrick nor Thin support streaming that way. You could try Mongrel or