sinatra

Sinatra: Undefined method 'run' when using bundle exec ruby app.rb

冷暖自知 提交于 2020-02-08 05:23:03
问题 I have modular style sinatra app, with the following line near the end, so that it can be run standalone: # ... all code before this omitted run! if __FILE__ == $0 end # This is the end of the file When I run this app with ruby app.rb it works fine, and webrick starts up. However, if I run it instead with bundle exec ruby app.rb I get this error: >bundle exec ruby app.rb C:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.4/lib/sinatra/base.rb:1488:in `start_server': undefined method `run' for

Why does code need to be reloaded in Rails 3?

折月煮酒 提交于 2020-01-27 07:23:32
问题 I am a former PHP developer learning Rails and Sinatra. In PHP, every page request loaded all of the required files. If I changed some code and refreshed the page, I could be sure that the code was fresh. In Rails 3, Controller code is fresh on every request. However, if I modify any code in the /lib folder, I need to restart the server so the changes take effect. Why does this happen? Is it something to do with the way Ruby is designed? Is Rails doing some optimizations to avoid reloading

Why does code need to be reloaded in Rails 3?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-27 07:21:29
问题 I am a former PHP developer learning Rails and Sinatra. In PHP, every page request loaded all of the required files. If I changed some code and refreshed the page, I could be sure that the code was fresh. In Rails 3, Controller code is fresh on every request. However, if I modify any code in the /lib folder, I need to restart the server so the changes take effect. Why does this happen? Is it something to do with the way Ruby is designed? Is Rails doing some optimizations to avoid reloading

Why does code need to be reloaded in Rails 3?

て烟熏妆下的殇ゞ 提交于 2020-01-27 07:19:35
问题 I am a former PHP developer learning Rails and Sinatra. In PHP, every page request loaded all of the required files. If I changed some code and refreshed the page, I could be sure that the code was fresh. In Rails 3, Controller code is fresh on every request. However, if I modify any code in the /lib folder, I need to restart the server so the changes take effect. Why does this happen? Is it something to do with the way Ruby is designed? Is Rails doing some optimizations to avoid reloading

How to validate header parameters with Sinatra?

旧时模样 提交于 2020-01-25 19:29:41
问题 I'm working on a simple API with Sinatra and I have a route like this one: get '/api/v1/invoice/:biller', :provides => [:json] do respond_with invoice( request ) end It works like a charm when I don't send any header params, but when I send: Accept Content-Type Then I got a 404 Not Found error and the classic Sinatra error 'Sinatra doesn't know this ditty' . How can I validate specific header params on Sinatra? Edit This is the actual header (Accept) with a curl example: curl -H "Accept:

How to validate header parameters with Sinatra?

大憨熊 提交于 2020-01-25 19:29:07
问题 I'm working on a simple API with Sinatra and I have a route like this one: get '/api/v1/invoice/:biller', :provides => [:json] do respond_with invoice( request ) end It works like a charm when I don't send any header params, but when I send: Accept Content-Type Then I got a 404 Not Found error and the classic Sinatra error 'Sinatra doesn't know this ditty' . How can I validate specific header params on Sinatra? Edit This is the actual header (Accept) with a curl example: curl -H "Accept:

Sinatra - response.set_cookie doesn't work

依然范特西╮ 提交于 2020-01-20 18:50:20
问题 I need to use a cookie for my Sinatra application. If I use the simpliest method is works: response.set_cookie('my_cookie', 'value_of_cookie') but I need some options such as domain and expire date so I try this: response.set_cookie("my_cookie", {:value => 'value_of_cookie', :domain => myDomain, :path => myPath, :expires => Date.new}) does not work. No cookie is made. I need this so much.... Please help... thanks! 回答1: The documentation on http://sinatra-book.gittr.com/#cookies says to use

Facebook Page Tab doesn't show my content

好久不见. 提交于 2020-01-16 19:25:11
问题 I'm trying to show some html in a facebook tab page without success.... I'm new in facebook applications and I do not understand what is happening. I've created a heroku app, to use your SSL, named https://sinatra-dev-test.herokuapp.com, this URL only shows a H1 with a "Teste" string. In my Sinatra Application I have a get route, and a post route that redirects to get. The heroku logs do not show nothing in particular, no one error or warning. Here is a screenshot to my facebook app config:

Problem pushing sqlite3 db to heroku: lib/taps/schema.rb:30:in `sqlite_config': undefined method `[]' for nil:NilClass (NoMethodError)

倾然丶 夕夏残阳落幕 提交于 2020-01-16 05:17:15
问题 I have a Sinatra DataMapper app hitting a sqlite3 database that I am attempting to deploy to Heroku. First pass, I included my database file in the git repo. This works, as in the app runs, but production data does not belong in the repository. It doesn't really work though because the database is read-only. I then removed the db file for source control and attempted a heroku db:push sqlite://db/my-app.db . This command yields the following stact trace: my-app/(master) ~ heroku db:push sqlite

Best way/practice to ensure links are going to proper location when not on root of domain?

落爺英雄遲暮 提交于 2020-01-16 02:28:27
问题 I've been wondering this for a while now, but what is the best way to ensure that in a web app (RoR, Sinatra, PHP, anything) that when you are creating links (either generating with a method, or writing in by hand) that they go to the proper place whether you are on the root of a domain or not: http://www.example.com/ or http://www.example.com/this/is/where/the/app/is/ My thoughts are get the end-user to specify a document root somewhere in the config of your app, and use that, however I'm