Hello, i have a strange problem here. I have made a teacher controller using scaffold. All actions work fine but the delete does not. When i click the delete link, it redirects me to the edit of this teacher. I have restarted the server and i have tried in firefox (i use chrome) but problem still remains. Here is the code from my view. <%= link_to(image_tag("/images/ delete_icon.jpg",:size=>"20x20",:border=>"0"), teacher, :confirm => ''Are you sure?'', :method => :delete)%> also tried but i get the same action <%= link_to ''Delete'', teacher, :confirm=>"Are you sure?", :method=>:delete %> The teacher_controller action is: # DELETE /teachers/1 # DELETE /teachers/1.xml def destroy @teacher = Teacher.find(params[:id]) @teacher.destroy respond_to do |format| format.html { redirect_to(teachers_url) } format.xml { head :ok } end end In the routes i only use resources :teachers. Any sollution with that?? Thank u i advance. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2010-Nov-04 11:56 UTC
Re: Delete action is not working and redirects to edit action
On 4 November 2010 11:23, Kostas L. <louposk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > i have a strange problem here. I have made a teacher controller using > scaffold. All actions work fine but the delete does not. When i click > the delete link, it redirects me to the edit of this teacher. I have > restarted the server and i have tried in firefox (i use chrome) but > problem still remains. Here is the code from my view.Have a look in the log file (log/development.log) to see what is logged when you click the link Colin> > <%= link_to(image_tag("/images/ > delete_icon.jpg",:size=>"20x20",:border=>"0"), teacher, :confirm => > ''Are you sure?'', :method => :delete)%> > > also tried but i get the same action > > <%= link_to ''Delete'', teacher, :confirm=>"Are you > sure?", :method=>:delete %> > > The teacher_controller action is: > # DELETE /teachers/1 > # DELETE /teachers/1.xml > def destroy > @teacher = Teacher.find(params[:id]) > -k4SasWvXw54qAwPp7cWvug@public.gmane.org > respond_to do |format| > format.html { redirect_to(teachers_url) } > format.xml { head :ok } > end > end > > In the routes i only use resources :teachers.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Arailsdemo A.
2010-Nov-04 13:57 UTC
Re: Delete action is not working and redirects to edit action
Sounds like you don''t have any javascript files in your Rails app. Remember that the destroy method uses javascript to work correctly. If javascript is missing, then the browser sends a POST request to your Rails server. If you send a post request to an existing record, you get the edit action. Make sure you have your javascript files included in confic/application.rb -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Arailsdemo A.
2010-Nov-04 14:41 UTC
Re: Delete action is not working and redirects to edit action
Oops. Correction on the above answer. It should be GET instead of POST. If there is no javascript, the delete link sends a get request to your server. A get request on an existing record gives you the edit action. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Kostas L.
2010-Nov-04 20:27 UTC
Re: Delete action is not working and redirects to edit action
Hi Colin, the log file shows the above: Started GET "/teachers" for 127.0.0.1 at Thu Nov 04 22:16:06 +0200 2010 Processing by TeachersController#index as HTML [1m [36mSQL (40.0ms) [0m [1m SELECT name FROM sqlite_master WHERE type = ''table'' AND NOT name = ''sqlite_sequence'' [0m [1m [35mTeacher Load (0.0ms) [0m SELECT "teachers".* FROM "teachers" Rendered shared/_header.html.erb (1.0ms) Rendered teachers/index.html.erb within layouts/teachers (31.0ms) Completed 200 OK in 467ms (Views: 59.0ms | ActiveRecord: 40.0ms) Started GET "/teachers/11" for 127.0.0.1 at Thu Nov 04 22:16:08 +0200 2010 Processing by TeachersController#show as HTML Parameters: {"id"=>"11"} [1m [36mTeacher Load (0.0ms) [0m [1mSELECT "teachers".* FROM "teachers" WHERE ("teachers"."id" = 11) LIMIT 1 [0m Rendered shared/_header.html.erb (2.0ms) Rendered teachers/show.html.erb within layouts/teachers (23.0ms) Completed 200 OK in 147ms (Views: 61.0ms | ActiveRecord: 0.0ms) Started GET "/teachers" for 127.0.0.1 at Thu Nov 04 22:16:09 +0200 2010 Processing by TeachersController#index as HTML [1m [35mTeacher Load (1.0ms) [0m SELECT "teachers".* FROM "teachers" Rendered shared/_header.html.erb (2.0ms) Rendered teachers/index.html.erb within layouts/teachers (29.0ms) Completed 200 OK in 55ms (Views: 43.0ms | ActiveRecord: 1.0ms) Do you see anything strange? Hi Arailsdemo, do i have to write something in the application.rb file?? I havent edited this file. The only thing i have inside is: require File.expand_path(''../boot'', __FILE__) require ''rails/all'' Bundler.require(:default, Rails.env) if defined?(Bundler) module Ptixiakes class Application < Rails::Application config.encoding = "utf-8" config.filter_parameters += [:password] end end Thank u in advance both Kostas On Nov 4, 4:41 pm, "Arailsdemo A." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Oops. Correction on the above answer. It should be GET instead of POST. > If there is no javascript, the delete link sends a get request to your > server. A get request on an existing record gives you the edit action. > > -- > Posted viahttp://www.ruby-forum.com/.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Colin Law
2010-Nov-04 21:14 UTC
Re: Re: Delete action is not working and redirects to edit action
On 4 November 2010 20:27, Kostas L. <louposk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Colin, > the log file shows the above: > > Started GET "/teachers" for 127.0.0.1 at Thu Nov 04 22:16:06 +0200 > 2010 > Processing by TeachersController#index as HTML > [1m [36mSQL (40.0ms) [0m [1m SELECT name > FROM sqlite_master > WHERE type = ''table'' AND NOT name = ''sqlite_sequence'' > [0m > [1m [35mTeacher Load (0.0ms) [0m SELECT "teachers".* FROM > "teachers" > Rendered shared/_header.html.erb (1.0ms) > Rendered teachers/index.html.erb within layouts/teachers (31.0ms) > Completed 200 OK in 467ms (Views: 59.0ms | ActiveRecord: 40.0ms) > > > Started GET "/teachers/11" for 127.0.0.1 at Thu Nov 04 22:16:08 +0200 > 2010 > Processing by TeachersController#show as HTML > Parameters: {"id"=>"11"} > [1m [36mTeacher Load (0.0ms) [0m [1mSELECT "teachers".* FROM > "teachers" WHERE ("teachers"."id" = 11) LIMIT 1 [0m > Rendered shared/_header.html.erb (2.0ms) > Rendered teachers/show.html.erb within layouts/teachers (23.0ms) > Completed 200 OK in 147ms (Views: 61.0ms | ActiveRecord: 0.0ms) > > > Started GET "/teachers" for 127.0.0.1 at Thu Nov 04 22:16:09 +0200 > 2010 > Processing by TeachersController#index as HTML > [1m [35mTeacher Load (1.0ms) [0m SELECT "teachers".* FROM > "teachers" > Rendered shared/_header.html.erb (2.0ms) > Rendered teachers/index.html.erb within layouts/teachers (29.0ms) > Completed 200 OK in 55ms (Views: 43.0ms | ActiveRecord: 1.0ms) > > Do you see anything strange?Well there is no POST for the delete apparently. At what point in the above did you click the delete link? If you are not sure then repeat it and note the times that you do things. Leave a bit between actions if necessary. Have you checked the html for your link to make sure it looks ok (View> Page Source or similar in your browser)?Colin> > Hi Arailsdemo, > do i have to write something in the application.rb file?? I havent > edited this file. The only thing i have inside is: > > require File.expand_path(''../boot'', __FILE__) > > require ''rails/all'' > > Bundler.require(:default, Rails.env) if defined?(Bundler) > > module Ptixiakes > class Application < Rails::Application > config.encoding = "utf-8" > config.filter_parameters += [:password] > end > end > > Thank u in advance both > Kostas > > On Nov 4, 4:41 pm, "Arailsdemo A." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Oops. Correction on the above answer. It should be GET instead of POST. >> If there is no javascript, the delete link sends a get request to your >> server. A get request on an existing record gives you the edit action. >> >> -- >> Posted viahttp://www.ruby-forum.com/. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
E. Litwin
2010-Nov-04 22:00 UTC
Re: Delete action is not working and redirects to edit action
On Nov 4, 4:23 am, "Kostas L." <loup...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > i have a strange problem here. I have made a teacher controller using > scaffold. All actions work fine but the delete does not. When i click > the delete link, it redirects me to the edit of this teacher. I have > restarted the server and i have tried in firefox (i use chrome) but > problem still remains. Here is the code from my view. >I had this same problem when starting a new Rails 3 project with jQuery. (I generated this project using a template from the Rails Wizard website.) If you are using jQuery, make sure you have the correct rails.js file (the jquery-rails gem will add rake tasks to help manage this). Also make sure that the jquery.min file is being loaded with the rails.js file My layout was using "javascript_include_tag :defaults", but only my rails.js file was getting loading. I fixed this by updating the config/application.rb file and modifying the "config.action_view.javascript_expansions[:defaults]" setting to add jquery.min. -- Eric -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
E. Litwin
2010-Nov-05 00:14 UTC
Re: Delete action is not working and redirects to edit action
On Nov 4, 3:00 pm, "E. Litwin" <elit...-ur4TIblo6goN+BqQ9rBEUg@public.gmane.org> wrote:> If you are using jQuery, make sure you have the correct rails.js file > (the jquery-rails gem will add rake tasks to help manage this).As a correction, the jquery-rails gem adds a generator (rails generate jquery:install), not rake tasks. -- Eric -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Colin Law
2010-Nov-05 08:26 UTC
Re: Delete action is not working and redirects to edit action
On 4 November 2010 11:23, Kostas L. <louposk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > i have a strange problem here. I have made a teacher controller using > scaffold. All actions work fine but the delete does not. When i click > the delete link, it redirects me to the edit of this teacher. I have > restarted the server and i have tried in firefox (i use chrome) but > problem still remains. Here is the code from my view. > > <%= link_to(image_tag("/images/ > delete_icon.jpg",:size=>"20x20",:border=>"0"), teacher, :confirm => > ''Are you sure?'', :method => :delete)%>Can you confirm whether you see the Are You Sure popup? If not then, as others have suggested, there is an issue with the javascript. Check that you have <%= javascript_include_tag :defaults %> in the layout (application.html.erb unless you have provided your own layout). Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Kostas L.
2010-Nov-05 23:58 UTC
Re: Delete action is not working and redirects to edit action
Hi guys, the problem was javascript!!! I''ve added this lines in my layout and it worked: <%= javascript_include_tag :defaults %> Thank you for your time!!!! Greetings Kostas -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.