Uploading a file from the browser
tokland is right (on both counts), you should push all that logic into a helper. You can also add a bit of OpenStruct into the mix to make the helper nicer:

# in app/helpers/application_helper.rb or another helper
def user_image_info(user)
    info = OpenStruct.new(:has_image? =&gt; false)
    return info if(!user.image?)

    # There might be better ways to do this but I don't know paperclip.
    u = user.image.url
    %w[jpeg gif png jpg csv].find do |ext|
        # A small abuse of `find` but reasonable in this case.
        info.is = "is#{ext.upcase}" if(u.include?(".#{ext}"))
    end
    if(info.is == 'isCSV')
        info.preview_link = '&lt;p&gt;Your file was a csv file and has no preview&lt;/p&gt;'.html_safe
    else
        info.preview_link = (image_tag(user.image.url) + '&lt;br&gt;').html_safe
    end
    info
end


Then in your ERB, you could do something like this:

&lt;% info = user_image_info(@user) %&gt;
&lt;% if info.has_image? %&gt;
    &lt;b&gt;&lt;%= info.is %&gt;&lt;/b&gt;
    &lt;%= info.preview_link %&gt;
    &lt;%= link_to @user.image.url, @user.image.url  %&gt;
&lt;% end %&gt;