0

I have following code in my view:

# panel.html.erb
<% if content.content_type == "image" && content.content_image_url =~ URI::ABS_URI %>
  <%= image_tag content.content_image.pinboard_thumb %>
<% elsif content.content_image? == false && content.content_value =~ URI::ABS_URI %>
  <%= image_tag content.content_value %>
<% else %>
  <%= auto_link content.content_value %>
<% end %>

I`m thinking where should I move this logic from if else block. How to do that Rails Way. Move that to helper??

Or is better way? Code below isn`t working.

tomekfranek
  • 6,852
  • 8
  • 45
  • 80

1 Answers1

0

Yes, a helper is the right place as the code seems to be about rendering only. So there is no business logic there. If you see yourself putting a lot of stuff like this into helpers, you could have a look at http://github.com/jcasimir/draper which is a gem that implements the presenter pattern.

moritz
  • 25,477
  • 3
  • 41
  • 36