[Rails] Re: Where to put large application controller code

2010-02-08 Thread Martin Berli
Aleksey Gureiev wrote: > I'm sorry, looked at the wrong page and didn't notice the ongoing > discussion. > > As you could see, I second that you don't need fat controllers and > that CSV processing logic belongs to a CSVProcessor model (not > module). It doesn't have a table, but it is a standalon

[Rails] Re: Where to put large application controller code

2010-02-08 Thread Aleksey Gureiev
I'm sorry, looked at the wrong page and didn't notice the ongoing discussion. As you could see, I second that you don't need fat controllers and that CSV processing logic belongs to a CSVProcessor model (not module). It doesn't have a table, but it is a standalone entity that knows how to work wit

[Rails] Re: Where to put large application controller code

2010-02-08 Thread Aleksey Gureiev
Hi Martin, That's a pretty common situation that you describe. One way, which is adopted by Rails team is to factor your related methods in modules and include them in your controllers. You can put those modules near your controllers or under /lib (which is loaded automatically). But before doing

[Rails] Re: Where to put large application controller code

2010-02-07 Thread Marnen Laibow-Koser
Martin Berli wrote: [...] > > Are you suggesting to put "everything" into a model, even if it's not > related to a database object? So to also put classes into the the > app/models directory, which are not of type ActiveRecord::Base ? Often, yes. Models are not only for database objects. Read

[Rails] Re: Where to put large application controller code

2010-02-07 Thread Martin Berli
Sharagoz -- wrote: > Code that doesn't fit neatly into a model, view or controller, or that > is shared across multiple models, views or controllers, should be > extracted into a module most of the time, and included where it needs to > be. Thanks, that's really what I needed. To put all the c

[Rails] Re: Where to put large application controller code

2010-02-07 Thread Sharagoz --
Code that doesn't fit neatly into a model, view or controller, or that is shared across multiple models, views or controllers, should be extracted into a module most of the time, and included where it needs to be. So if you have some controller code like the CSV processing that you mentioned, i

[Rails] Re: Where to put large application controller code

2010-02-07 Thread Martin Berli
Sharagoz -- wrote: > If your controllers are getting fat it might be an indication that you > are putting a lot of the logic in the wrong place and not using the MVC > architecture the way its ment to be used. "Skinny controller, fat model" > is the practice most try to follow. The "calculation

[Rails] Re: Where to put large application controller code

2010-02-07 Thread Sharagoz --
If your controllers are getting fat it might be an indication that you are putting a lot of the logic in the wrong place and not using the MVC architecture the way its ment to be used. "Skinny controller, fat model" is the practice most try to follow. The "calculation detail" usually belongs in