After seeing DestroyAllSoftware screencasts from Gary Bernhardt, reading this post http://solnic.eu/2011/08/01/making-activerecord-models-thin.html , talking with some people about the issue and based on my personal experience, I found that they''re all right. So I''m on a new project trying to follow this path in making AR Models just a thin layer to the DB, specially responsible for db persistance. The thing is, that I have to move the business logic to "application models" that will live somewhere else (for example, app/libs). But I''m really struggling to find a way to do that. Basically, the problem is: - my OO thinking is too "ActiveRecord Driven". My first thinking was doing models that wraps in a 1 by 1 scenario an AR model. For example, for a User AR model, I should have a User "application" model, that will do the business logic related. This is appearing to be really wrong to me. There are clear advantages but now I''m free of rails AR and can create abstract concepts free from the framework bindings. If you can give me some nice samples (maybe github projects) for me to see exactly how people are doing this stuff, probably I could force my mind into thinking about new patterns. Even some textbook would be nice, should I read the entire Martin Fowler collection? HUHUH In advance, thanks for your help ;) Forgive me if the text isn''t perfectly correct, english is a foreign language for me.. :/ -- Sebastião Giacheto Ferreira Júnior "How much trust is too much trust? Should you even trust?" -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 10 May 2012 04:14, Sebastião G. Ferreira Júnior <sebastorama-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> After seeing DestroyAllSoftware screencasts from Gary Bernhardt, > reading this post > http://solnic.eu/2011/08/01/making-activerecord-models-thin.html , > talking with some people about the issue and based on my personal > experience, I found that they''re all right. So I''m on a new project > trying to follow this path in making AR Models just a thin layer to > the DB, specially responsible for db persistance. > > The thing is, that I have to move the business logic to "application > models" that will live somewhere else (for example, app/libs). But I''m > really struggling to find a way to do that. Basically, the problem is: > - my OO thinking is too "ActiveRecord Driven". My first thinking was > doing models that wraps in a 1 by 1 scenario an AR model. For example, > for a User AR model, I should have a User "application" model, that > will do the business logic related. This is appearing to be really > wrong to me. There are clear advantages but now I''m free of rails AR > and can create abstract concepts free from the framework bindings.You can just put the application models in the models folder as normal. Remember that models do not have to be AR based. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sebastião G. Ferreira Júnior
2012-May-10 19:03 UTC
Re: Thin Controllers, Thin AR Models too!
A guy named "M Daubs" sent an e-mail directly to me recommending me to read the book "Objects on Rails". So I think I should share here: http://objectsonrails.com/ (free html version, USD5 for kindle/pdf drm free..). In answer to Colin Law, Thanks for your reply. But this is not really a technical question. I just want to see some great examples of what I can do when designing the model layer of my application. I wan''t to know where to include Modules or use Inheritance and so on, but the question is always about design. But thanks :D Sorry for missing the "[Rails]" inside the thread subject =/ On Thu, May 10, 2012 at 4:48 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 10 May 2012 04:14, Sebastião G. Ferreira Júnior > <sebastorama-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> After seeing DestroyAllSoftware screencasts from Gary Bernhardt, >> reading this post >> http://solnic.eu/2011/08/01/making-activerecord-models-thin.html , >> talking with some people about the issue and based on my personal >> experience, I found that they''re all right. So I''m on a new project >> trying to follow this path in making AR Models just a thin layer to >> the DB, specially responsible for db persistance. >> >> The thing is, that I have to move the business logic to "application >> models" that will live somewhere else (for example, app/libs). But I''m >> really struggling to find a way to do that. Basically, the problem is: >> - my OO thinking is too "ActiveRecord Driven". My first thinking was >> doing models that wraps in a 1 by 1 scenario an AR model. For example, >> for a User AR model, I should have a User "application" model, that >> will do the business logic related. This is appearing to be really >> wrong to me. There are clear advantages but now I''m free of rails AR >> and can create abstract concepts free from the framework bindings. > > You can just put the application models in the models folder as > normal. Remember that models do not have to be AR based. > > Colin > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Sebastião Giacheto Ferreira Júnior "How much trust is too much trust? Should you even trust?" -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.