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 that I would also consider moving your logic to
models to keep your controllers skinny. The fact that you have many
private methods signals that you probably have a lot of logic in your
controllers. That's not a very good thing unless there's no other
choice.

- Aleksey

On Feb 7, 10:48 pm, Martin Berli <li...@ruby-forum.com> wrote:
> Hello,
>
> A common experience: You start to develop a new rails application. When
> controller method code is growing, you will put parts of its code under
> the private section at the end of the controller, because you want the
> public methods to reflect the processing logic, not the calculation
> detail. Later on, this private controller section is also growing. You
> detect that it consists of many private methods, which could be grouped
> thematically. What is best practice now? Creating my own classes and
> putting them into the rails lib directory? These classes would be of
> singleton type, because it would make no sense to instantiate them more
> than once: they are just a collection of thematically grouped methods,
> not really an "object".
>
> Instead of putting the classes under the lib directory, one could also
> create app/my_logic/ directories,
> and put the classes there. Is there any difference? Of course, in the
> last case, one would have to tell rails to also look into the my_logic
> directories...
>
> What's your experience? What is best practice, to keep the overview over
> your code?
>
> Thanks and regards,
> Martin
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to