In my gemfile, I have gem 'stringex'
. After running bundle install
, I added a path helper and am using a method that is from stringex. I should be able to use to_url
directly on a string, like the example in the stringex readme: "simple English".to_url => "simple-english"
.
However, when I try to use the method .to_url on a string in my path helper, I get:
undefined method 'to_url' for "fake title":String
My helper method looks something like:
module PostsHelper
def post_path(post)
"/posts/#{post.id}/#{post.title.to_url}"
end
end
One thing that you can try is running bundle exec irb
and then trying to require "stringex"
. If you can't require the gem in properly, then it's not installed in the bundle.
您需要在posts_helper.rb
文件的顶部添加posts_helper.rb
require 'stringex'
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.