Topic: [Share]How to Call Library File From Model

You may experience this problem while developing web application with Ruby On Rails. You have succeeded calling library on your controller, but you fail to call it from your model. How to deal with such problem?

To deal with such problem, you only need to replace one word on your codes. If you call library from your controller like this one.

include Your_Library_Name

Then you have to call library from your model like this one.

extend Your_Library_Name

Please notice this one. To call library from your model, you need to replace include with extend. I have tried it and it works for Rails 2.3.7 along with Ruby 1.8.7. Please let me know if it doesn't work for yours.

Source : … model.html