Jason Yost
Jason Yost

Reputation: 4937

Where to store class in ruby on rails

I need to create a class with some properties and methods for my application where should I store the class file in a ruby on rails app?

Upvotes: 4

Views: 1458

Answers (2)

sameera207
sameera207

Reputation: 16619

It actually depends. in rails when you are considering MVC architecture, all the Models and views are classes. while models often inherited from AR and controllers are from ActionController::Base

it depends of what actually your new class will gonna do.

1 - if it something regarding the business logic, like creating different kind of users according to logged in user (Admin, NormalUser) you might be keeping it inside models.

2 - If your new class have some common methods which will be used by models or controllers and used by those (like extending, or injecting new methods) you can store them in the lib folder.

so if you could post some more details, we might be able to helpyou more :D

cheers

sameera

Upvotes: 5

Nikita Rybak
Nikita Rybak

Reputation: 68006

lib folder is usually a good place, if that's not a model.

Upvotes: 1

Related Questions