Reputation: 1391
I have a rails application. For one of my models, I created a specific class which will probably never be used anywhere else than in this specific model.
Where should I place the file corresponding to this class and its corresponding test file?
I currently placed it in /lib but since it will never be used elsewhere, I don't think that this is the right place for it.
Upvotes: 0
Views: 109
Reputation: 140
As @jstim says there is no specific way.
But you can use the presenters or decorates for this
In app directory create a folder as presenters or decorators.
Create a file some_file.eb In this you can create the class and use it in any controller you want.
app/presenters/some_file.eb
class ClassName
def your_method
end
end
Upvotes: 0
Reputation: 2432
I don't think there's a categorically correct answer to this question, because the class can be put in a few different locations that all make it available to the program and it's more a matter of organizational preference.
tl;dr lib is just fine.
app/models/user/password.rb
for User::Password
lib/soap_client.rb
Exception
class or the like perhaps?Upvotes: 3