Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Rails helpers to render partials

From my understanding, helpers are mainly used to clean up views from some view-specific logic.

But on my currently new project (legacy application), I've stumbled upon a lot of helpers that look like this

def itemprepare
  render :partial => 'items/itemlist_summary'
end

Is this correct? Rendering a partial to me seems like something you would want to do in the view, as it doesn't include any logic that needs to be abstracted.

Should I just inline all of these helpers?

like image 715
Jakub Arnold Avatar asked Jan 02 '12 12:01

Jakub Arnold


1 Answers

Rendering a partial doesn't belong in a helper. Helpers should help you to do things that contain logic. Logic doesn't belong in the controller unless it's logic to render partials and decide if something should be displayed or not.

like image 169
davidb Avatar answered Sep 20 '22 16:09

davidb