sinatra

Hot deploy Ruby just like PHP: FTP upload file and valid immediately

人走茶凉 提交于 2019-12-06 11:21:35
Is it possible to hot deploy Ruby just like PHP? Normally I used FTP to upload the PHP file, then it will be available automatically. Can Ruby hot deploy its file like this? Your comment welcome. Are you talking about a ruby on rails application ? If so, when deploying a rails application in production mode, the all application gets loaded in memory. So changing the files won't affect the running application. For hot restarting a rails application you will need to use solution such as: Unicorn Puma Passenger For a first time, Puma is the easiest way. However if you are looking for a zero

Adaptive images for ruby based servers

假装没事ソ 提交于 2019-12-06 10:38:00
I'd like to deliver images to client based on the size of the user screen, as in If I have High resolution image, and the user want to view it on a mobile I don't want to send the full HD image, instead I'd like to send the image shrinked to the user's device dimension which will increase the loading speed on low bandwidth devices There is a solution for this here Adaptive Images detects your visitor's screen size and automatically creates, caches, and delivers device appropriate re-scaled versions of your web page's embeded HTML images.It is intended for use with Responsive Designs and to be

Why would I get “Errno::ENOENT: No such file or directory” when viewing a Sinatra form?

こ雲淡風輕ζ 提交于 2019-12-06 09:43:55
I am trying to follow this tutorial: http://net.tutsplus.com/tutorials/ruby/singing-with-sinatra/ Got stuck in "We’ll also make use of a “ view file ”, which allows us to split the markup for a view into a separate file. " I have my basics.rb file running fine. And My files are stored as follows: Desktop/RubyForm/basics.rb Desktop/RubyForm/view/form.erb However, now when i go to http://localhost:9393/form , I am greeted with: Errno::EIO at /form Input/output error - <STDERR> file: lint.rb location: write line: 398 sinatra.error Errno::ENOENT: No such file or directory - /Users/HelenasMac

how to make a sinatra app run in rails 4?

自闭症网瘾萝莉.ら 提交于 2019-12-06 09:43:44
问题 I have a Sinatra app and I'd like to start building new functionality in Rails while still supporting the existing Sinatra functionality. I've tried the following strategies: sinatra's rackup routes some requests to rails and some to sinatra sinatra's rackup includes rails rails' rackup includes sinatra. Many of my searches resulted in rails 3, not 4. Additionally, does Rails have to generate the db versus using one that Sinatra was using (in this case, the Sequel gem to access Sqlite3.) In

How to deploy a modular Sinatra app to Heroku?

余生长醉 提交于 2019-12-06 08:14:10
For some reason, I can't access any files in the public dir. Not found error. I'm not putting the public part in the URL, obviously. View the Lovers source code repository on GitHub . Sweet. I fixed this. After reading about Sinatra Configurations , I added this line to my application class: set :root, Lovers.root That worked! 来源: https://stackoverflow.com/questions/4989711/how-to-deploy-a-modular-sinatra-app-to-heroku

Simple Search With Datamapper and Sinatra

南笙酒味 提交于 2019-12-06 07:16:51
问题 I'm fairly new to Ruby and backend development in general. That being said I'm trying to create a simple search form. I'm using Sinatra as the framework and Datamapper as my ORM. What is the best way to do this? Below is my schema I would like the search action to search both the tile and category. require 'sinatra' require 'datamapper' DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/cal.db") class Event include DataMapper::Resource property :id, Serial property :title, String property :text

Simple way to test an HTTPS (SSL) request with RSpec

纵饮孤独 提交于 2019-12-06 07:01:09
I want Rspec to request the root using https. This is what I currently have: it "requesting root (/) with HTTPS should return 200" do get "https://test.host/" last_response.should be_ok end Attempting the solution proposed in Test an HTTPS (SSL) request in RSpec Rails returns the following error: wrong number of arguments (0 for 1) I would assume I could do something like: get "/", :https => "on" Is there a way to request the root without specifying the host? When using Sinatra and RSpec, you are using the #get/#post methods provided by Rack::Test , so I suggest you look there to see how they

Sinatra - terminate server from request

吃可爱长大的小学妹 提交于 2019-12-06 06:46:54
问题 I want to be able to terminate a Sinatra app from a request, e.g. with the following route: post '/terminate' do Thread.current.kill end Implementing it like this is a bit abrupt. I'd rather the request completed, returned an HTTP OK message, and then Sinatra shut down gracefully. Is there a hook to do this? Edit: My application is a lightweight mock server used for receiving webhook notifications. I will be using multiple servers like this on the same machine (different ports), so need to

How do I log asynchronous thin+sinatra+rack requests?

十年热恋 提交于 2019-12-06 05:47:51
问题 I'm writing my first Sinatra-based web app as a frontend to another TCP-based service, using EventMachine and async_sinatra to process incoming HTTP requests asynchronously. When I'm testing my app, all requests to synchronous routes are logged to stdout in common log format, but asynchronous requests are not. I've read through bits of the source code to async_sinatra, Sinatra, Thin, and Rack, and it looks like logging of synchronous requests is done through CommonLogger#call. However, I can

DataMapper - Single Table Inheritance

≯℡__Kan透↙ 提交于 2019-12-06 05:21:11
Could Some one please explain to me what is going on here? This is an example that I put together to show y'all whats up: class Person include DataMapper::Resource property :id, Serial property :type, Discriminator property :name, String property :age, Integer end class Male < Person end class Father < Male property :job, String end class Son < Male end class Female < Person end class Mother < Female property :favorite_song, String end class Daughter < Female end DataMapper.auto_upgrade! If I call Person.all I get: Person.all => [#<Son @id=1 @type=Son @name="Mike" @age=23 @status=nil>, #<Son