sinatra

sinatra app doesn't start on run

a 夏天 提交于 2019-12-13 12:38:27
问题 I'm on Ubuntu 10.10/Ruby 1.9.2 Whatever I do, I can't get a sinatra app to start on my local machine. hello.rb: require 'sinatra' get '/' do "Hello World!" end "$ ruby hello.rb" and "$ ruby -rubygems hello.rb" both result in a new prompt with no action taken. Any tips or pointers? 回答1: This is a known issue in Sinatra 1.0 running on Ruby 1.9.2 ; it has been fixed in Sinatra 1.1 which is just around the corner. Fix it with enable :run : require 'sinatra' enable :run get '/' do "Hello World!"

Sinatra rack middleware hijacks '/' root url

只愿长相守 提交于 2019-12-13 12:22:51
问题 I'm trying to use a Sinatra app as middleware in my Rails app. I've tested a basic Sinatra app in the /lib folder of the Rails app, use d the middleware and set a route. That worked fine. What I want to be able to do is extract the Sinatra app and include it as a gem. That way I can run the Sinatra app independently, or use it in multiple Rails apps. Sinatra App # myrackapp/lib/myrackapp.rb module Myrackapp class Application < Sinatra::Base set :root, File.dirname(__FILE__) get "/" do "Rack

How to ship a Sinatra application as a gem and deploy it?

痴心易碎 提交于 2019-12-13 11:50:28
问题 I have a sinatra application and packaged that as a gem. Its file-layout looks roughly like this: ├── bin │ └── tubemp ├── lib │ └── tubemp.rb ├── Gemfile └── tubemp.gemspec I can install and run it just fine. Calling ruby lib/tubemp.rb fires the app too, because Sinatra made it self-starting. tubemp.rb : class Tubemp < Sinatra::Application get '/' do erb :index, :locals => { :title => "YouTube embeds without third party trackers." } end end The binary is really simple too. bin/tubemp : #!

Derived Activerecord Ruby Class

别说谁变了你拦得住时间么 提交于 2019-12-13 06:13:24
问题 I am totally new to ruby. I am trying to make a RESTful service for task tracking application. I researched and found Sinatra better for the job than rails. So I am using Sinatra and ActiveRecord. I am following Up and Running With Sinatra and ActiveRecord. I will be creating the client application in .NET using Restsharp. But this is all about server side. This is the migration I have created class CreateTasksPeopleDocumentsAndComments < ActiveRecord::Migration def self.up create_table

How to redirect web page from a specfic page in Sinatra?

怎甘沉沦 提交于 2019-12-13 04:41:58
问题 In Sinatra, how to redirect a web page from a specific page? require 'sinatra' get "/A" do redirect '/B' end get "/B" do # if comes from A # "IT COMES FROM A" # else not from A # "NOT FROM A , REDIRECT TO C" # redirect '/C' # end end I want to learn how to do this? Can I use JavaScript or HTML to do what I want to do? Or, it must be done in Sinatra? I tried this, but it keeps null , get "/B" do mypath = URI(request.referer || '').path if mypath == '/A' "hi i am b , u come from a" else "--#

HTTP calls behave different locally vs AWS - is it ruby or AWS?

走远了吗. 提交于 2019-12-13 04:39:22
问题 I have a weird problem with an API I'm writing. The API has makes http get requests to other services and times out in certain situations- another service being off/unreachable in most cases. I'm trying to run the system entirely on AWS, but when running the API on there I get frequent timeouts trying to access services on the same instance. The API is written in ruby+sinatra; I never had problems with its python predecessor. If I curl the url for other services from the AWS instance command

mootools accordion not working

╄→尐↘猪︶ㄣ 提交于 2019-12-13 04:32:02
问题 I've been wanting to try out the Accordion effect on mootools but I can't get it to work, it's just like the js doesn't load at all this is the HTML code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>BarDiJan - We Deliver</title> <link rel="stylesheet" href="/stylesheets/reset.css"

Possible to redirect AND show content with Sinatra?

为君一笑 提交于 2019-12-13 04:14:07
问题 I'd like to do a redirect with a Sinatra route AND show a redirection message. So http://api.mysite.com/product/123.html would do this redirect product.url, 301 AND output "redirecting..." Is this possible, and what would the code look like? 回答1: From the Sinatra documentation for redirect: Any additional parameters are handled like arguments passed to halt : redirect to('/bar'), 303 redirect 'http://google.com', 'wrong place, buddy' and for halting: You can also specify the status when

heroku db:push sqlite://mydatabase.db error

天大地大妈咪最大 提交于 2019-12-13 04:10:15
问题 **When I do "heroku db:push sqlite://mydatabase.db" I have a problem with Ruby + Sinatra + Sqlite3 + Heroku : When i do : "heroku db:push sqlite://anotador.db" Console log: 2013-01-21T12:37:11+00:00 app[web.1]: Errno::ENOENT - No such file or directory - /app/views/home.erb: 2013-01-21T12:37:11+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:572:in `erb' My anotador.rb : require 'rubygems' require 'sinatra' require 'data_mapper' DataMapper::setup(

Sinatra error when handling .php routes

你。 提交于 2019-12-13 04:08:17
问题 I'm creating a Sinatra app to replace a legacy PHP based app. get '/page.php' do # ... do something end I'm trying to define a route like this but I get "Sinatra doesn't know this ditty." error page. At the top of the page, I have this configure do mime_type :php, 'text/html' end Any idea how to tell Sinatra to use the whole path including the file extension as part of it? 来源: https://stackoverflow.com/questions/11343991/sinatra-error-when-handling-php-routes