我正在尝试在Dreamhost共享服务器上运行Ruby on Rails应用程序.到目前为止一切都很好,除了一个我无法解开的奇怪的错误.
有时当我访问网络应用程序时,我收到一个Phusion Passenger错误说,
您已经激活了机架1.2.1,但您的Gemfile需要机架1.2.2.考虑使用bundle exec.
当我只是刷新页面时,它似乎工作,但没有更多的Phusion Passenger错误消息.
在其他堆栈溢出线程和类似的Dreamhost wiki之后,我将以下内容添加到config/environment.rb
文件的顶部:
if ENV['RAILS_ENV'] == 'production' # don't bother on dev
ENV['GEM_PATH'] = '/home/myusername/.gems' + ':/usr/lib/ruby/gems/1.8'
end
Run Code Online (Sandbox Code Playgroud)
我很好奇我在定义函数时应该使用模式匹配vs guard子句.
例如,使用模式匹配:
defmodule Exponent do
def power(value, 0), do: 1
def power(value, n), do: value*power(value, n-1)
end
Run Code Online (Sandbox Code Playgroud)
vs护卫条款:
defmodule Exponent do
def power(value, n) when n==0, do: 1
def power(value, n), do: value*power(value, n-1)
end
Run Code Online (Sandbox Code Playgroud)
我的意思是两者产生相同的结果,但是一种优先于另一种的解决方案?如果是这样,为什么?
我是Elixir的新手,所以这个问题的答案对我来说还不是很明显.提前致谢.
我使用RVM在Ubuntu 12.04上安装Ruby 1.9.3
rvm pkg install openssl
rvm install 1.9.3 --with-openssl-dir=$rvm_path/usr
Run Code Online (Sandbox Code Playgroud)
然后当我尝试按照以下方式运行时:
require 'open-uri'
open('https://www.google.com/')
Run Code Online (Sandbox Code Playgroud)
我收到错误: OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
我该如何解决这个问题?我有许多类似的线程,人们在OSX中有这个问题,但我如何在Ubuntu中解决它?
谢谢你的帮助.
我刚开始一个新的rails项目,想通过Mongoid gem使用MongoidDB.按照Mongoid网站上的说明,我向我添加了以下行Gemfile
:
gem "mongoid", "~> 2.4"
gem "bson_ext", "~> 1.5"
Run Code Online (Sandbox Code Playgroud)
然后我database.yml
按照此处的说明继续删除我的文件.我的application.rb
文件现在看起来像这样:
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
require "sprockets/railtie" # Uncomment this line for Rails 3.1+
Run Code Online (Sandbox Code Playgroud)
现在,当我用于rails s
在开发中启动我的服务器时,我收到以下错误:
~/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/railtie/configuration.rb:85:in `method_missing': undefined method `active_record' for #<Rails::Application::Configuration:0x007ff38b20d0b0> (NoMethodError)
Run Code Online (Sandbox Code Playgroud)
我试着找一个解决方案,但似乎还没有人遇到我的问题.难道我做错了什么?这是由最近的Rails 3.2更新引起的吗?
谢谢你的帮助!
更新(1月26日): 根据Dylan Markow的信息,我使用了terminal命令
grep -r active_record config/
Run Code Online (Sandbox Code Playgroud)
并在评论块中将任何引用放入active_record.
我有一个简单的控制器,其中一个动作甚至还没有打到数据库.当我通过浏览器访问操作时,我得到了
ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished):
activerecord (3.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
activerecord (3.2.0) lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
activerecord (3.2.0) lib/active_record/query_cache.rb:67:in `rescue in call' …
Run Code Online (Sandbox Code Playgroud) 我有兴趣在我的Ruby on Rails应用程序中添加一个博客.我不想浪费我的时间在rails中编写一个bloggin应用程序 - 我可以做到,但我只是喜欢更强大的东西.
我调查了Wordpress,它似乎是最好的博客平台之一.我的问题是如何将Wordpress集成到我的网站中?我最好使用我现有的rails布局和CSS.这类事情是否可能.
我的网站是http://www.arenpatel.com/,作为最终结果,我希望在博客上生成相同的Rails生成侧边栏(Twitter feed).
也许有一个Rails替代Wordpress?
谢谢您的帮助!
我必须使用Adobe InDesign来创建文档.我们基本上需要在整个文档中包含一些需要填写的变量(公司名称,项目名称等).
我想知道是否有办法采用exisitng模板,并且可能使用我熟悉的语言(Ruby,Python等)逐步填充这些模板.我试图使用文本编辑器打开Adobe InDesign文件 - 但是当我使用Notepad ++进行修改然后在InDesign中打开文件时,它会告诉我文件已损坏.
如果您有任何洞察力,以编程方式构建InDesign文档或了解任何非常感谢的教程.
PS.我试图查看Adobe的ExtendScript,但没有找到适用于InDesign的文档.
谢谢您的帮助!
Map
在下面的示例中使用, :
const m = new Map<number, string>();
m.set(1, 'one');
console.log(m.get(1)); // correct way to access the value residing at 1
console.log(m[1]); // incorrect - why is this allowed? how do I prevent this kind of usage?
Run Code Online (Sandbox Code Playgroud)
运行上面的代码块会产生以下输出:
one
undefined
Run Code Online (Sandbox Code Playgroud)
我很好奇,为什么 TS/ESLint 允许方括号访问?难道编译器和/或 linter 不应该知道m
类型变量Map
不会响应方括号访问器吗?有没有办法配置 TS 或 ESLint 来警告/错误这些类型的不正确用法(特别是在使用该Map
类型时)?
我有一个运行乘客的共享服务器来服务我的Rails应用程序.出于某种原因,我的RAILS_ENV变量似乎被卡在'开发'中.如何将其设置为"生产"?谢谢
我有一个上游服务器,它经常通过返回“Set-Cookie”响应头来设置 Cookie。
我想在上述上游服务器前面有一个 nginx 代理:
Browser => Nginx => Upstream
Run Code Online (Sandbox Code Playgroud)
如果Browser => Nginx
请求有标头,X-No-Cookies: true
我希望响应Upstream => Nginx => Browser
不包含Set-Cookie
响应标头。如果X-No-Cookies
有任何其他值,我会撒谎Set-Cookie
返回未更改的响应标头。我无法更改上游服务器的响应标头行为。
目前我的nginx配置如下,具体注意proxy_hide_header
指令的使用。我还在响应头中回显了该$proxy_hide_header
变量X-No-Cookies
。
map $http_x_no_cookies $proxy_hide_header {
default "";
"true" "Set-Cookie";
}
# Homepage
server {
listen 80;
server_name example.com;
location /api {
proxy_pass https://example.com/api;
proxy_hide_header $proxy_hide_header;
add_header "X-No-Cookies" $proxy_hide_header;
}
}
Run Code Online (Sandbox Code Playgroud)
当我使用 cURL 发出请求时:
curl \
http://example.com/api \
-H 'X-No-Cookies: true' \
-I
Run Code Online (Sandbox Code Playgroud)
我得到以下响应标头: …