# Tidy Controllers

**URL:** <https://www.ruby-forum.com/t/tidy-controllers/125424>\
**Category:** Rails\
**Created:** [January 8, 2008, 11:53pm UTC](https://www.ruby-forum.com/t/tidy-controllers/125424 "2008-01-08T23:53:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![galeal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@galeal](https://www.ruby-forum.com/u/galeal)\
**Post date:** [January 8, 2008, 11:53pm UTC](https://www.ruby-forum.com/t/tidy-controllers/125424/1 "2008-01-08T23:53:44Z")

</div>

I’m currently working on tidying up some code, I realized that the  
controller had a lot of Model logic in it, so naturally I moved it out  
to the corresponding models.

But there’s also a lot of AJAX calls happening in the controller as  
well. Is there any recommended way to keep it tidy? i.e. best practices  
and what not.

TIA  
Luke

---

<div class="post-metadata">

**Author:** ![galeal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@galeal](https://www.ruby-forum.com/u/galeal)\
**Post date:** [January 9, 2008, 1:14am UTC](https://www.ruby-forum.com/t/tidy-controllers/125424/2 "2008-01-09T01:14:06Z")

</div>

What do you mean AJAX calls happening in the controller? If you mean  
something like this:

render :update do |page|  
page.blah blah  
page.blah blah  
end

then that should be moved to the views folder under the ‘action.js.rjs’  
name and then used like this

respond\_to |format|  
format.js  
end
