rack

Ruby Rack Heroku: Serving Static Files

ぃ、小莉子 提交于 2019-12-11 03:21:54
问题 I have followed the Heroku guide on deploying static files using Ruby Rack (https://devcenter.heroku.com/articles/static-sites-ruby), but I was unable to access any HTML file in \public apart from index.html . Namely, localhost:9292/test.html still maps to index.html . (All my style and js files serve correctly). Below is my config.ru file. I know what's wrong, but not sure about a valid solution? use Rack::Static, :urls => ["/images", "/js", "/css"], :root => "public" run lambda { |env| [

How can I pass data to websocket-rack from a class in my sinatra app?

你。 提交于 2019-12-11 03:07:08
问题 I've got a working configuration of websocket-rack in a sinatra app that is intended for a physical installation with multiple screens. There is functionality working where messages are getting passed back and forth through the websockets just fine. My problem is this: I have one page with a standard web form (i.e. not a websocket form), and my goal is to collect the params from that form, turn the params into a string variable, then send the contents of that variable (a string) to a

How to get ruby on rails production mount-point included in url_helpers for email?

允我心安 提交于 2019-12-11 02:54:46
问题 tl;dnr : My page links are fine, but links erb-olated into non-page text (email) lack the production app mount-point. detail : My RoR app uses slightly different URLs in dev and production: in dev, the top-level entity is the resource model: http://localhost:3000/ENTITY/1/edit But in production, the app is mounted one level down, so URLS have an extra term: https://server.example.com/APP/ENTITY/1/edit This works fine for most cases: url_helpers like edit_entity_url return the URLs as I've

How to load forked github repo as gem in sinatra/rack application

穿精又带淫゛_ 提交于 2019-12-11 02:48:29
问题 I'm trying to use a gem called "rbing" but there is an issue with it and the project has been abandoned but someone made a fix in a repo so I decided to use bundler to specify the new version. gem "rbing", :git => "https://github.com/KellyMahan/rbing.git" It even installed correctly when I ran bundle install, but inside my Gemfile RubyMine is complaining that "The gem with the specified version requirements isn't available inside SDK RVM: ruby-2.0.0" And it doesn't show up in my external

How to make unicorn run a Rails 3.0 app under a path?

余生长醉 提交于 2019-12-11 01:55:44
问题 I'm migrating from Passenger to Unicorn, and with Passenger I used to run my Rails 3.0 app with the RailsBaseURI option to prefix all URLs with '/blah' for example. When running the same app under Unicorn, I pass '--path /blah' to unicorn_rails, but the server still serves things as http://server:3000/etc/etc, instead of http://server:3000/blah/etc/etc - I see some assets being requested via /blah/ (like JS files, and so on), but the various links still do not have '/blah/' before them. So -

What's the base URL for my app?

自闭症网瘾萝莉.ら 提交于 2019-12-11 01:38:12
问题 In Camping/Rack, how can I get the base URL for my app? I want to know so I can put it in an email it sends. It might be (in development) or http://localhost:9292 or http://localhost:80/game or in production http://fancy-snake.heroku.com 回答1: Camping has a helper called URL which returns the absolute URL to your app: URL() # => #<URL:http://test.ing/blog/> URL() + "view/12" # => #<URL:http://test.ing/blog/view/12> URL("/view/12") # => #<URL:http://test.ing/blog/view/12> 回答2: So far I have url

Sinatra on Passenger always fails on first attempt

感情迁移 提交于 2019-12-10 23:08:47
问题 I have a small Sinatra app I'm running on a shared hosting account using Passenger. However, the first time the app is accessed after a while, I get a Passenger error page saying the application could not be started. Usually because Sinatra could not be found. I am assuming this is just a normal delay from when a new instance is spawned. However, is there a way to delay trying to load Siantra until it Passenger has fully loaded? 回答1: I seem to have solved the issue by setting the GEMS_PATH

Streaming web uploads to socket with Rack

五迷三道 提交于 2019-12-10 22:32:25
问题 I currently have a Sinatra app running in an FCGI handler. I want to write a handler that will sit within the rackup file (probably in front of the Sinatra app) and will stream big file uploads to another server via sockets (without buffering it on disk first) and do so in interlock with the request. So what I would like to do is some kind of stream-decode-send workflow without param preparsing. I've read somewhere that there is a problem with this because specifically due to the way the

Testing Rails Metal/Rack with RSpec?

隐身守侯 提交于 2019-12-10 21:54:08
问题 Say I have a Metal class named Preview. How do I test it with RSpec? When I try: require 'spec_helper' describe Preview do it "should return the posted content" do post "/preview", :content => "*title*" response.body.should == "*title*" end end I get: undefined method `post' for #<ActiveSupport::TestCase::Subclass_1:0x1058b3098> It seems that RSpec doesn't load up the :post method if the test isn't explicitly for a Controller. I've tried specifying :type => :controller to no avail. 回答1: rspec

Can't activate rack (~> 1.4.0, runtime) already activated rack-1.5.0

随声附和 提交于 2019-12-10 21:16:13
问题 I've been looking for an answer to this for over a day now, and searched StackOverflow thoroughly. I understand the conflict that's happening, and I should just uninstall the version of Rack I don't need, but here's the thing. I'm developing on Koding (http://koding.com) and I don't have access to system level gems. Rails was working before, I installed the mongo gem, removed it, and installed mysql2 gem. bash4.1$ rails /usr/lib/ruby/site_ruby/1.8/rubygems.rb:233:in `activate': can't activate