I have a simple class I want to include in my Rails app, but I want to still be able to access all the Rails niceness, e.g use the gems, helpers, routes etc etc as normal.
How can I do this? Is it the right thing to do?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You didn’t quite specify what the class is for. If it’s a model, put it in the models folder. Don’t forget that a model doesn’t have to be backed by a database. If you have a class that represents something and has business logic, it’s a model.
The lib folder is also appropriate, but depending on how you name the file and the class definition, you may still need to require it from environment.rb or elsewhere.
Another approach is to use a plugin or a gem to distribute your code.