2012-05-12 55 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文件的頂部。

相關問題