我被困在试图继续使用RoR.我做了Ruby Installfest,但遇到了我认为是openssl.bundle的问题.
我正在使用RVM,并且正在运行Rails 5.0.1和Ruby 2.4.0
我尝试使用完全删除/重新开始,rvm implode然后重新安装并重新安装RailsApps指南后的所有内容,但仍然看到相同的错误.我正在运行最新版本的macOS Sierra.
这是我在my_app中运行$ Rake -T时得到的输出.
richsmith@Richs-MacBook-Pro:~/workspace/myapp$ rake -T
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::VERSION
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::OPENSSL_VERSION
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::OPENSSL_LIBRARY_VERSION
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::OPENSSL_VERSION_NUMBER
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::OPENSSL_FIPS
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::Config::DEFAULT_CONFIG_FILE
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::Signer
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::TEXT
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::NOCERTS
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: already initialized constant OpenSSL::PKCS7::NOSIGS
/Users/richsmith/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/x86_64-darwin16/openssl.bundle: warning: …Run Code Online (Sandbox Code Playgroud) 我试图让 Markdown 与 .erb 很好地配合。我想使用 high_voltage 来呈现用 Redcarpet 解析的降价页面(或带有降价部分的普通 .html.erb 文件),并且正在努力让它一起工作。
目前我有一个markdown_template_handler.rb包含以下代码的初始化程序:
class MarkdownTemplateHandler
def erb
@erb ||= ActionView::Template.registered_template_handler(:erb)
end
def call(template)
compiled_source = erb.call(template)
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
"#{markdown.render(compiled_source.source).inspect}.html_safe;"
end
end
ActionView::Template.register_template_handler(:md, MarkdownTemplateHandler.new)
Run Code Online (Sandbox Code Playgroud)
但是它在第 7 行失败,compiled_source = erb.call(template)错误代码说“参数数量错误(给定 1,预期为 2)”
我查看了ERB Ruby 文档,但据我了解,call 方法是新方法的派生,它只需要 1 个参数,即文本。但是,当我尝试仅在快速 rails 控制台会话中使用它时,它还需要两个参数。
当我从上面的代码中删除解析 erb 的要求时,一切都按预期工作,所以我认为这与 Redcarpet 不工作没有任何关系。
我正在使用 Rails v6.0.0.rc1 & Ruby v2.5.3p105
任何帮助表示赞赏。
编辑
进一步的研究使我找到了Rails 6.0 ERB ActionView 模板处理程序。这个处理程序的调用方法确实需要两个参数,模板和源。也就是说,在Rails 5.2.3 中,ERB 操作视图模板处理程序调用方法只需要一个参数,即模板。
有人可以指出我在这种情况下找出什么 …
I'm struggling to wrap my mind around an ActiveRecord query.
I'm trying to search my database for GolfRetailer objects with ID's 1..100, that have something (not nil) in their :website field, and that don't have true in their duplicate_domain field.
Here's the query I expected to work:
GolfRetailer.where.not(website: nil, duplicate_domain: true).where(id: 1..100)
I also tried this variant of essentially the same query: GolfRetailer.where.not(website: nil).where(id: 1..100, duplicate_domain: !true)
But both return an empty array, despite there definitely being records that …