2012-05-12 56 views
3

在我的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 
+0

好像你的宝石没有安装。你是否尝试手动添加对该宝石的引用? –

回答

1

一你可以尝试的东西是运行bundle exec irb,然后尝试require "stringex"。如果您不能正确地要求宝石,那么它不会安装在捆绑包中。

0

您需要将require 'stringex'添加到posts_helper.rb文件的顶部。

相关问题