gpt4 book ai didi

ruby-on-rails - 即使安装了正确的 gem,rails 中的 NoMethodError

转载 作者:数据小太阳 更新时间:2023-10-29 08:10:04 26 4
gpt4 key购买 nike

在我的 gemfile 中,我有 gem 'stringex'。运行 bundle install 后,我添加了一个路径助手,并使用了来自 stringex 的方法。我应该能够直接在字符串上使用 to_url,就像 stringex 自述文件中的示例:"simple English".to_url => "simple-english".

但是,当我尝试在我的路径助手中的字符串上使用 .to_url 方法时,我得到:

“假标题”的未定义方法“to_url”:String

我的辅助方法类似于:

module PostsHelper
def post_path(post)
"/posts/#{post.id}/#{post.title.to_url}"
end
end

最佳答案

您可以尝试的一件事是运行 bundle exec irb 然后尝试 require "stringex"。如果你不能正确地要求 gem,那么它就不会安装在 bundle 中。

关于ruby-on-rails - 即使安装了正确的 gem,rails 中的 NoMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10564873/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com