Jonathan Martin
-
Rails 3: Auto Require
~ by Jonathan Martin
During the process of coding my blog, I came across the need for a truncation feature (another post in and of itself). So I made a new file under the lib directory called string.rb which added a truncate_html function to the String class. Lo and behold, whenever I called the function, the console printed an error stating that no such function existed.
In Rails 3, lib files are lazy loaded — this can be adjusted by adding the first line to the config/application.rb file. Restarted the server, but still I received the error.