Hi Guys,
I have installed the attatchment_fu plugin and got it working so can
upload images to my application. I used Mike C.'s Weblog as a
guide. http://clarkware.com/cgi/blosxom/2007/02/24#FileUploadFu.
I can upload images no problem but there seems to be no way of
deleting the images from the articles, and I have been scratching my
head all morning as to how to accomplish this.
module Admin::ArticlesHelper
def article_image_for(article)
if article.article_image
article_img = article.article_image.public_filename
link_to image_tag(article_img),
article.article_image.public_filename
#else
#image_tag(“blank-image.png”)
end
end
end
Articles _form.html.erb
<%= article_image_for(@article) %>
<% else %>You can upload an image for this article below
<% end %><%= label :article, :article_image %>
<%= file_field_tag :article_image_file %>
Acceptable file formats include JPEG,
PNG or GIF upto 500kb in size and 500px in width
class CreateArticleImages < ActiveRecord::Migration
def self.up
create_table :article_images do |t|
t.integer :article_id, :parent_id, :size, :width, :height
t.string :content_type, :filename, :thumbnail
t.timestamps
end
end
def self.down
drop_table :article_images
end
end