Hi Guys,
I have installed the attatchment_fu plugin and got it working so can
upload images to my application. I used Mike Clark''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
<p>
	<%= article_image_for(@article) %>
</p>
	<% else %>
<p>
	You can upload an image for this article below
</p>
	<% end %>
	<%= label :article, :article_image %>
	<%= file_field_tag :article_image_file %>
	<br />
	<span class="supported-files">Acceptable file formats include
JPEG,
PNG or GIF upto 500kb in size and 500px in width</span>
</p>
--------------------------------------------------------------------------------------
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I created a button on the form page
<%= button_to "Delete Image", { :action =>
"delete_article_image", :article_image_id =>
@article.article_image.id } %>
and in my articles controller I created the following method;
def delete_article_image
		@article_image = ArticleImage.find(params[:article_image_id])
		@article_image.destroy
		respond_to do |format|
			format.html { redirect_to(admin_articles_url) }
			format.xml	{ head :ok }
		end
	end
This code does not throw up any errors, but it does not delete the
record in the article_images table
Any help would be greatly appreciated
On Dec 4, 10:56 am, denver
<louis.ba...-0JJ/7AHcgqF4YaK/0CqiW1pr/1R2p/CL@public.gmane.org>
wrote:> Hi Guys,
>
> I have installed the attatchment_fu plugin and got it working so can
> upload images to my application. I used Mike Clark''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
> <p>
>         <%= article_image_for(@article) %>
>
> </p>
>         <% else %>
> <p>
>         You can upload an image for this article below
> </p>
>         <% end %>
>
>         <%= label :article, :article_image %>
>         <%= file_field_tag :article_image_file %>
>         <br />
>
>         <span class="supported-files">Acceptable file
formats include JPEG,
> PNG or GIF upto 500kb in size and 500px in width</span>
> </p>
> ---------------------------------------------------------------------------
-----------
>
> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Ive also tried
def delete_article_image
		@article = Article.find(params[:id])
		@article_image = @article.article_image
		@article_image.destroy
		respond_to do |format|
			format.html { redirect_to(admin_articles_url) }
			format.xml	{ head :ok }
		end
	end
but it still does not remove the entry from the database.... please
help guys
On Dec 4, 11:10 am, denver
<louis.ba...-0JJ/7AHcgqF4YaK/0CqiW1pr/1R2p/CL@public.gmane.org>
wrote:> I created a button on the form page
>
> <%= button_to "Delete Image", { :action =>
> "delete_article_image", :article_image_id =>
> @article.article_image.id } %>
>
> and in my articles controller I created the following method;
>
> def delete_article_image
>                 @article_image =
ArticleImage.find(params[:article_image_id])
>                 @article_image.destroy
>
>                 respond_to do |format|
>                         format.html { redirect_to(admin_articles_url) }
>                         format.xml      { head :ok }
>                 end
>         end
>
> This code does not throw up any errors, but it does not delete the
> record in the article_images table
>
> Any help would be greatly appreciated
>
> On Dec 4, 10:56 am, denver
<louis.ba...-0JJ/7AHcgqF4YaK/0CqiW1pr/1R2p/CL@public.gmane.org> wrote:
>
> > Hi Guys,
>
> > I have installed the attatchment_fu plugin and got it working so can
> > upload images to my application. I used Mike Clark''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
> > <p>
> >         <%= article_image_for(@article) %>
>
> > </p>
> >         <% else %>
> > <p>
> >         You can upload an image for this article below
> > </p>
> >         <% end %>
>
> >         <%= label :article, :article_image %>
> >         <%= file_field_tag :article_image_file %>
> >         <br />
>
> >         <span class="supported-files">Acceptable file
formats include JPEG,
> > PNG or GIF upto 500kb in size and 500px in width</span>
> > </p>
> >
---------------------------------------------------------------------------
-----------
>
> > 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
dont worry. i fixed the problem. it was because the button was inside a _form page and so the variables were not passed across On Dec 4, 12:28 pm, denver <louis.ba...-0JJ/7AHcgqF4YaK/0CqiW1pr/1R2p/CL@public.gmane.org> wrote:> Ive also tried > > def delete_article_image > @article = Article.find(params[:id]) > @article_image = @article.article_image > @article_image.destroy > > respond_to do |format| > format.html { redirect_to(admin_articles_url) } > format.xml { head :ok } > end > end > > but it still does not remove the entry from the database.... please > help guys > > On Dec 4, 11:10 am, denver <louis.ba...-0JJ/7AHcgqF4YaK/0CqiW1pr/1R2p/CL@public.gmane.org> wrote: > > > I created a button on the form page > > > <%= button_to "Delete Image", { :action => > > "delete_article_image", :article_image_id => > > @article.article_image.id } %> > > > and in my articles controller I created the following method; > > > def delete_article_image > > @article_image = ArticleImage.find(params[:article_image_id]) > > @article_image.destroy > > > respond_to do |format| > > format.html { redirect_to(admin_articles_url) } > > format.xml { head :ok } > > end > > end > > > This code does not throw up any errors, but it does not delete the > > record in the article_images table > > > Any help would be greatly appreciated > > > On Dec 4, 10:56 am, denver <louis.ba...-0JJ/7AHcgqF4YaK/0CqiW1pr/1R2p/CL@public.gmane.org> wrote: > > > > Hi Guys, > > > > I have installed the attatchment_fu plugin and got it working so can > > > upload images to my application. I used Mike Clark''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 > > > <p> > > > <%= article_image_for(@article) %> > > > > </p> > > > <% else %> > > > <p> > > > You can upload an image for this article below > > > </p> > > > <% end %> > > > > <%= label :article, :article_image %> > > > <%= file_field_tag :article_image_file %> > > > <br /> > > > > <span class="supported-files">Acceptable file formats include JPEG, > > > PNG or GIF upto 500kb in size and 500px in width</span> > > > </p> > > > --------------------------------------------------------------------------- ----------- > > > > 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---