草庐IT

sinatra-assetpack

全部标签

ruby - Thin & Sinatra 不接受端口

我在使用Thin和Sinatra设置我的应用程序时遇到问题。我创建了一个包含以下设置的development-config.ru文件:#ThisisarackconfigurationfiletofireuptheSinatraapplication.#Thisallowsbettercontrolandconfigurationasweareusingthemodular#approachhereforcontrollingourapplication.##ExtendtheRubyloadpathwiththerootoftheAPIandthelibfolder#sothatwe

ruby - 当我访问 AppFog 上的 Sinatra 应用程序时显示 "Forbidden"消息

我将一个简单的Sinatra应用程序上传到AppFog。它在我的本地机器上运行良好。但是在将应用程序上传到AppFog后,当我访问AppFogdomain时会显示一个带有“禁止”消息的页面。.这些是appFog日志:====>/logs/stderr.log/W,[2012-06-01T06:32:54.393022#28933]WARN--:attackpreventedbyRack::Protection::IPSpoofing211.32.146.42--[01/Jun/201206:32:54]"GET/favicon.icoHTTP/1.1"403-0.000210.0.64

ruby - Sinatra 'hello world' 中的错误

做gettingstarted辛纳屈。我收到此错误:./sinatra.rb:5:undefinedmethod`get'formain:Object(NoMethodError)from/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in`gem_original_require'from/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in`require'fromsinatra.rb:3谷歌搜索这些错误返回rubyLoadError:can

ruby - Sinatra 应用程序找不到 View 目录

我正在尝试创建一个模块化的sinatra应用程序,并且需要我的每个子应用程序在我的项目文件夹的根目录中查找views目录。但它只在子目录本身而不是根目录中查找views目录。这是我的项目的样子:├──config.ru├──music_catalog│  └──app.rb├──public│  ├──css│  │  └──site.css│  └──images│  ├──content_top_bg.jpg│  ├──demo_image_01.jpg│  ├──god_save_http_it_aint_no_human_being.png│  ├──header_bg.jpg

用于下载文件的 Ruby Sinatra 应用程序(作为流媒体)

我有一个sinatra应用程序,我想在其中添加下载功能。此下载从表中获取数据并制作excel以供用户下载。require'csv'get'/download'dodata=[{:name=>"john",:age=>12,:state=>'ca'},{:name=>"tony",:age=>22,:state=>'va'}]#Iwanttodownloadthisdataasexcelfileandthecontentoffileshouldbeasfollows:#name,age,state#john,12,ca#tony,22,va#Idon'twanttosavedataasa

ruby - 使用 Sinatra 1.3 发送二进制流

我正在构建一个Sinatra应用程序,它需要向用户发送刚刚从其他地方(本质上是代理)下载的文件。虽然我有大部分工作,但我无法让Sinatra发送我的代码中指定的正确文件名。我使用的代码是:get'/'doattachmentfile.nameheaders['Content-Type']=file.content_typeheaders['Content-Disposition']='attachment'file.bodyend(file.body为文件内容)如何让Sinatra使用我想要的文件名? 最佳答案 headers["C

ruby - 使用 Sinatra 和 Rack Logger 记录时如何过滤敏感信息

我维护一个充当JSONAPI服务的Sinatra应用程序。该API由另一个网络应用程序和移动应用程序使用。我想让Rack::CommonLogger从其日志中排除敏感信息,例如密码。Rails启用了此设置,但我没有找到如何在Sinatra中执行此操作的文档。 最佳答案 您可以像这样尝试拦截写入和过滤掉敏感消息的调用:logger=Logger.new("my_common.log")logger.instance_evaldodefwrite(msg)self.send(:然后,配置Rack::CommonLogger来使用这个记录

ruby - Sinatra 请求对象

我可能在这里遗漏了一些非常明显的东西,但我似乎找不到答案,也无法自己解决。在Sinatra中,他们有一个self.get方法,它捕获block,当一个block被调用时,你可以在里面使用request变量,这怎么可能?西纳特拉moduleSinatraclassBaseclassRequest应用classApp 最佳答案 哇。你激起了我的好奇心,果然,研究这个很有趣。魔法开始于compile!定义的方法:https://github.com/sinatra/sinatra/blob/master/lib/sinatra/base.

Ruby/Sinatra 应用程序(文件)不运行(启动)

我正在使用:ruby-1.9.3-p392和sinatra-1.4.3。当我运行我的文件时,我得到了这个错误:/home/belka/.rvm/gems/ruby-1.9.3-p392@Rails3.2.13/gems/sinatra-1.4.3/lib/sinatra/base.rb:1408:in`run!':undefinedmethod`run'forHTTP:Module(NoMethodError)from/home/belka/.rvm/gems/ruby-1.9.3-p392@Rails3.2.13/gems/sinatra-1.4.3/lib/sinatra/main

ruby - Sinatra 单元测试 - 使用 JSON 正文发布

我正在尝试为我使用Sinatra构建的RESTAPI构建单元测试。现在我只想测试我的回声功能是否正常工作。Echo使用POST并将返回与帖子完全相同的有效负载。我对ruby​​还是个新手,所以如果我使用的术语不正确,请原谅我。这是我要测试的代码:post'/echo'dorequest.body.readend这是我要进行的单元测试:ENV['RACK_ENV']='test'require'./rest_server'require'test/unit'require'rack/test'require'json'classRestServer使用上面的代码,这里是错误:NoMeth