This helper is simply because I’m lazy. Instead of typing out the longer image_tag url_for_file_column(blah, blah, blah)
, I simplified my life a little.
In addition, it makes it easier for my list view to be able to use the paging instead of redoing the finds with extra conditions; and I can use the helper from anywhere in the site since it’s in the application_helper.rb.
def get_image(id)
@photo = ListingImages.find(id)
image_tag url_for_file_column(@photo, "image", "thumb")
end
Call it from anywhere in your views with
get_image(photo.id)
Now isn’t get_image much shorter than the alternative?
You’ve got to love the simplicity of Rails!
file_column website