Why I couldn't require 'string.rb' file in ruby -


I am applying the gem, I want to add some custom methods to the string class. Therefore, I have created the 'lib' directory sub-directory 'core_ext', and placed the 'string.rb' file there. string / Pre>

I have created in my main file:

  is required 'core_ext / string.rb' P> but its string has no effect on class,  

If I change the file name to another name, like 'my_string.rb' and change the line with requirement, then everything will work properly. Why can not I use 'string.rb' as the file name?

If there is a file name core_ext / string which loads from anywhere else It's done, it is also loaded one. You may need to come up with a different name.

Ruby 1.9 has a needed_relative feature that p11y states that this is a better solution.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -