草庐IT

Rack-local

全部标签

ruby - 如何解析 "Your bundle only supports platforms ["x86-mingw3 2"] but your local platforms are ["ruby​​", "x86_64-linux"]"

我正在Windows机器上构建一个Rails站点,但是当我检查我的Gemfile.lock时,我在我的Travis构建中遇到以下错误:Yourbundleonlysupportsplatforms["x86-mingw32"]butyourlocalplatformsare["ruby","x86_64-linux"],andthere'snocompatiblematchbetweenthosetwo列表这是完整的日志:https://travis-ci.org/bikebike/BikeBike/builds/222395810#L654我查看了我的Gemfile.lock并指出:

ruby-on-rails - gem install nokogiri -v '1.5.11' 由于 make :/usr/local/bin/gmkdir: No such file or directory 而失败

Rubyversion:2.2.5MacOSX:10.11.5Gemversion:2.4.8Bundlerversion:1.12.5当我运行geminstallnokogiri-v'1.5.11'时,出现以下错误:Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingnokogiri:ERROR:Failedtobuildgemnativeextension./Users/hwpeng/.rvm/rubies/ruby-2.2.5/bin/ruby-r./siteconf20160707-31800-

ruby-on-rails - 缺少带有 { :locale=>[:en], :formats=>[:html], 的模板布局/邮件程序

我正在学习michaelharltrails教程,但出现此错误Missingtemplatelayouts/mailerwith{:locale=>[:en],:formats=>[:html],:variants=>[],:handlers=>[:raw,:erb,:html,:builder,:ruby,:coffee,:jbuilder]}.Searchedin:*"/home/ubuntu/workspace/app/views"预览账户激活时这是我的user_mailer.rbclassUserMailer错误突出显示了mailto:user.email,subject:"A

Spring 国际化遇到的坑 No message found under code ‘xxx.xxxx‘ for locale ‘zh_CN‘

Spring国际化遇到的坑org.springframework.context.NoSuchMessageException:Nomessagefoundundercode‘xxx.xxxx’forlocale‘zh_CN’背景以前做的项目客户群体只有国内的客户,从来没有考虑过语言文字的问题。这次有一个需求的返回内容,要根据客户设置的语言返回不同的语言。尝试使用了以后,结果发现怎么都不好使,一直报的一个错误如下:org.springframework.context.NoSuchMessageException:Nomessagefoundundercode'user.name'forloc

ruby - Rack::Session::Pool 与 Sinatra

我有一个使用enable:sessions构建的Sinatrawebapp,我使用session[:mything]访问我的session数据。我现在想在服务器端存储数据(即使用基于数据库的session),但我不知道如何使用Rack::Session::Pool,这似乎是我需要使用的东西。我如何着手转换我的网络应用程序以与Pool一起使用?我知道我需要添加行useRack::Session::Pool接下来会发生什么?—提前致谢!编辑:这是一个使用基于cookie的session的示例:require'rubygems'require'sinatra'enable:sessionsg

ruby - 如何使用 Rack 为特定文件设置内容类型?

我想让Rack提供具有特定内容类型的特定文件。它是一个.htc文件,需要作为text/x-component提供,以便IE识别它。在apache中我会这样做AddTypetext/x-component.htc如何使用Rack实现这一目标?目前该文件由Rack::Static提供,但我没有找到设置内容类型的选项。 最佳答案 您可以像这样更新您的config/initializers/mime_types.rb:#Besuretorestartyourserverwhenyoumodifythisfile.#Addnewmimetyp

ruby-on-rails - 使用 Upstart 管理 Unicorn w/rbenv + bundler binstubs w/ruby-local-exec shebang

好吧,这让我的大脑融化了。这可能与我不了解Upstart以及我应该了解的事实有关。对于这么长的问题提前致歉。我正在尝试使用Upstart来管理Rails应用程序的Unicorn主进程。这是我现在的/etc/init/app.conf:description"app"startonrunlevel[2]stoponrunlevel[016]consoleowner#expectdaemonscriptAPP_ROOT=/home/deploy/appPATH=/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:$PATH$APP_ROOT/

ruby - -bash :/usr/local/bin/heroku:/usr/local/bin/ruby: bad interpreter: No such file or directory

每当我打开一个新的终端窗口时,我现在得到:-bash:/usr/local/bin/heroku:/usr/local/bin/ruby:错误的解释器:没有那个文件或目录知道为什么会发生这种情况以及如何摆脱它吗? 最佳答案 确保文件/usr/local/bin/heroku的第一行是#!/path/to/ruby。您可能需要将其从/usr/local/bin/ruby更改为/usr/bin/ruby,或者如果找不到ruby可执行文件,键入whichruby​​或updatedb&&locateruby​​找到它。如果上述方法不起作用

ruby - 如何将一个 config.ru 文件变成一个单独的 Rack 应用程序?

我有一个开始有重复代码的config.ru文件:map'/route1'dorunSampleApp.newendmap'/route2'dorunSampleApp.newend我想把这个config.ru文件变成它自己的Rack应用程序,这样我所要做的就是:map'/'dorunMyApp.newend创建自己的Rack应用程序的正确方法是什么?具体来说,我如何创建一个类,以便我可以在我的类中使用map方法来定义一堆路由?解决方法:这是一个可行的解决方案:classMyAppdefinitialize@app=Rack::Builder.newdo#copycontentsofyo

ruby - Heroku 上 Rack::Static 应用程序的 HTTP 基本身份验证

我在Heroku上托管了一个简单的Rack应用程序。配置.ru:useRack::Static,:urls=>["/stylesheets","/images","/javascripts"],:root=>"public"runlambda{|env|[200,{'Content-Type'=>'text/html','Cache-Control'=>'public,max-age=86400'},File.open('public/index.html',File::RDONLY)]}如何向其中添加HTTP基本身份验证?如果它只适用于生产环境,则加分。谢谢