Amazon.com Widgets
...not so private reflections of greg.newman
RSS feed - Categories & Search

Shorter Column - A File_Column Helper

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&#095;image(id)<br /> &#xA0;&#xA0;&#xA0; @photo = ListingImages.find(id)<br /> &#xA0;&#xA0;&#xA0; image&#095;tag url&#095;for&#095;file&#095;column(@photo, "image", "thumb")<br /> end
Call it from anywhere in your views with
get&#095;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

2 Comments

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

thank you, nice write up!

Leave a comment