In Rails, is it ok to define logic in a controller with a model. For example, take there is an User Model, which is good design.
1)Leaving the UserModel with the CRUD models and moving all the other User Specific actions to a separate controller or
2)Add the user specific actions to the same UserModels
Thanks 🙂
I would prefer following approach
creating a separate User model in a different name space like business (to represent business login) and It will have all the business logic and there will be a separate user model which derives from ActiveRecord
example would be
class Business::User
#inside this all the user business logic goes
#you might need User (ORM) model when required like find action
end
and my controller will communicate with Business::User and this class will communicate with User (ORM) class for database actions
class User < ActiveRecord::Base
end
By this way you can separate your business login and ORM. either way you should keep your controllers thin while giving more processing to your models
cheers,
sameera