在我的gem文件中,我有gem 'stringex'
。在运行bundle install
之后,我添加了一个路径助手并使用来自strictgex的方法。我应该可以直接在字符串上使用to_url
,如在严格自述文件中的示例:"simple English".to_url => "simple-english"
。即使安装了正确的宝石,在轨道中的NoMethodError
然而,当我尝试使用方法.to_url上串在我的路径帮手,我得到:
undefined method 'to_url' for "fake title":String
帮助我的方法看起来是这样的:
module PostsHelper
def post_path(post)
"/posts/#{post.id}/#{post.title.to_url}"
end
end
好像你的宝石没有安装。你是否尝试手动添加对该宝石的引用? –