Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Begginers Rails Issue - destroy method being called out of the blue

Reply
Thread Tools

Begginers Rails Issue - destroy method being called out of the blue

 
 
the noob
Guest
Posts: n/a
 
      06-23-2006
Hello, I'm just starting with ruby-rails and having a weird issue.
Starting from a basic scaffolding I've altered the list method/view to
display a group of images. Im using file_column for file handling.
Since I got the basics working I've had an issue with items
disappearing off my list. Now that i've learned to use the logs I see
that the destroy method is being called, but im not doing it. I have
protected the method with the :confirm option on the link and a
"before_filter :login_required" in the controller. So I'll be coding
away switching from my list view to another im working on over and over
and suddenly one of the images is gone. When I looked into it I see
that the record has been deleted from the database and file column has
done its thing and removed the image file from my file system. I can't
find other people complaining about this so I'm guessing i've made a
coding error. Any tips on how to troubleshoot this?

Probably unrelated but I have one other issue with the destroy method.
The link I use on my list view to call destroy has the :confirm option.
But when I test it I sometimes get an error saying the item is not
found. So I tried clicking the link and didn't do anything to the
confirm message that popped up. I checked my database and filesystem
and the entry is already gone. The logs indicate that the destroy
method was called. With the confirm dialog still onscreen. ??

I'm running on windows/apache 2/scgi. This issue has occured on cgi,
fcgi, and scgi.

Thanks for reading.

 
Reply With Quote
 
 
 
 
Senthilnayagam
Guest
Posts: n/a
 
      06-24-2006
Strange problem,

never faced this problem

could you confirm from your apache log calls to "destroy" are "POST"
requests and not "GET"

if they are post and it is your browser, could be browser bug, please
try some other browser, firefox, opera or internet explorer

if they are get requests, in your destroy action verify request method
is post in your destroy method.


if request.post?
#destroy action
else
flash[:notice]="illegal delete call"
end

hope this helps for now,


regards
A.Senthil Nayagam

http://senthilnayagam.com

the noob wrote:
> Hello, I'm just starting with ruby-rails and having a weird issue.
> Starting from a basic scaffolding I've altered the list method/view to
> display a group of images. Im using file_column for file handling.
> Since I got the basics working I've had an issue with items
> disappearing off my list. Now that i've learned to use the logs I see
> that the destroy method is being called, but im not doing it. I have
> protected the method with the :confirm option on the link and a
> "before_filter :login_required" in the controller. So I'll be coding
> away switching from my list view to another im working on over and over
> and suddenly one of the images is gone. When I looked into it I see
> that the record has been deleted from the database and file column has
> done its thing and removed the image file from my file system. I can't
> find other people complaining about this so I'm guessing i've made a
> coding error. Any tips on how to troubleshoot this?
>
> Probably unrelated but I have one other issue with the destroy method.
> The link I use on my list view to call destroy has the :confirm option.
> But when I test it I sometimes get an error saying the item is not
> found. So I tried clicking the link and didn't do anything to the
> confirm message that popped up. I checked my database and filesystem
> and the entry is already gone. The logs indicate that the destroy
> method was called. With the confirm dialog still onscreen. ??
>
> I'm running on windows/apache 2/scgi. This issue has occured on cgi,
> fcgi, and scgi.
>
> Thanks for reading.


 
Reply With Quote
 
 
 
 
the noob
Guest
Posts: n/a
 
      06-25-2006
Thanks Senthilnayagam, The logs show the destroy requests are GET. I
put the code you proveded into my method and i'm getting the illegal
delete call error whe I use the delete link. I take it that these
requests should be POST? I don't see any options availble on the
destroy method. Any suggestions on a fix?

 
Reply With Quote
 
Martin DeMello
Guest
Posts: n/a
 
      06-25-2006
the noob <(E-Mail Removed)> wrote:
> Thanks Senthilnayagam, The logs show the destroy requests are GET. I
> put the code you proveded into my method and i'm getting the illegal
> delete call error whe I use the delete link. I take it that these
> requests should be POST? I don't see any options availble on the
> destroy method. Any suggestions on a fix?


if request.post? wasn't pesudocode - it's the actual syntax to see if
the incoming request is a POST

Can't remember the syntax offhand, but there's also a way to use a
before_filter to protect a bunch of actions at once from being called by
anything other than a POST - ask on the rails mailing list.

martin
 
Reply With Quote
 
Senthilnayagam
Guest
Posts: n/a
 
      06-25-2006
So my assumption was right, your browser was the culprit

some browser plugins, trozans, seem to access all the url's we browse
and send it back to their core sites.

test with a alternative browser, remove the offending plugin.

scaffold is supposed to get you a kickstart, but anything that goes
production, especially the code which is not under password protection
and accessible by bots and public should be duly tested

regards
A.Senthil Nayagam
http://senthilnayagam.com


the noob wrote:
> Thanks Senthilnayagam, The logs show the destroy requests are GET. I
> put the code you proveded into my method and i'm getting the illegal
> delete call error whe I use the delete link. I take it that these
> requests should be POST? I don't see any options availble on the
> destroy method. Any suggestions on a fix?


 
Reply With Quote
 
Timothy Goddard
Guest
Posts: n/a
 
      06-25-2006
Are you using a web accelerator of some sort? These will load links on
pages and often ignore javascript confirmation dialogs. You can block
them by looking for telltale headers.

the noob wrote:
> Hello, I'm just starting with ruby-rails and having a weird issue.
> Starting from a basic scaffolding I've altered the list method/view to
> display a group of images. Im using file_column for file handling.
> Since I got the basics working I've had an issue with items
> disappearing off my list. Now that i've learned to use the logs I see
> that the destroy method is being called, but im not doing it. I have
> protected the method with the :confirm option on the link and a
> "before_filter :login_required" in the controller. So I'll be coding
> away switching from my list view to another im working on over and over
> and suddenly one of the images is gone. When I looked into it I see
> that the record has been deleted from the database and file column has
> done its thing and removed the image file from my file system. I can't
> find other people complaining about this so I'm guessing i've made a
> coding error. Any tips on how to troubleshoot this?
>
> Probably unrelated but I have one other issue with the destroy method.
> The link I use on my list view to call destroy has the :confirm option.
> But when I test it I sometimes get an error saying the item is not
> found. So I tried clicking the link and didn't do anything to the
> confirm message that popped up. I checked my database and filesystem
> and the entry is already gone. The logs indicate that the destroy
> method was called. With the confirm dialog still onscreen. ??
>
> I'm running on windows/apache 2/scgi. This issue has occured on cgi,
> fcgi, and scgi.
>
> Thanks for reading.


 
Reply With Quote
 
the noob
Guest
Posts: n/a
 
      06-26-2006
Thank you for your responses. The code Senthilnayagam provided has
stopped me from loosing data but now I cannot run the destroy method
myself. When I click the destroy link it is making a GET request.
>From your respounses I take it that this should be POST. Any idea why

my own requests are being processed as GET's? This happens on fresh
copies of IE and firefox.

*Timothy Goddard* - Thanks for that tip. I do use google web
accelerator and you prompted me to do some research. I found this
article:

http://37signals.com/svn/archives2/g..._designers.php

Which sounds exactly like the problem I'm having. I'm putting in the
code to stop prefetching now. I will let it roll for a few days and
come back with the results. Although the GET/POST issue is
interesting the prefetching plug-in may be the root cause.

 
Reply With Quote
 
the noob
Guest
Posts: n/a
 
      06-26-2006
I got it.. have to add a {post => true} to my link_to helper. Again,
thanks for your help . I'm still going to cut off google pre-cache.

 
Reply With Quote
 
the noob
Guest
Posts: n/a
 
      06-29-2006
Just want to confirm that the above steps solved my problem.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WebService called by automation dll times out when being called from Navision Felix ASP .Net Web Services 1 09-29-2006 01:43 PM
Compleated Begginers Guide. Now What? Jay Python 10 04-12-2006 01:52 PM
When to destroy, when not to destroy Ook C++ 2 10-11-2005 02:11 AM
Begginers questions on different distributions of py Player Python 7 08-25-2004 04:45 PM
Init called without calling destroy in JServ Ajit Java 1 08-08-2003 06:22 PM



Advertisments