Home > Not Working > Rails Link_to Method Delete Not Working

Rails Link_to Method Delete Not Working


Is the untested/empty statement true? http://blog.8thcolor.com/en/2011/08/nested-resources-with-independent-views-in-ruby-on-rails/ I'm also trying to learn how to use the web console and pry within it. I used a solution that I happened to already have on my laptop on an exam. This doesn't seem to be happening. http://elliottwaveresearch.com/not-working/object-doesn-39-t-support-property-or-method-39-getelementsbyclassname-39-ie-11.html

Any tips? asked 5 years ago viewed 19564 times active 2 years ago Upcoming Events 2016 Community Moderator Election ends in 9 days Linked 11 Rails 3 link_to generator for :post, :put, & I had this same issue, and this line of code made my delete link work again. I'm using ruby 2.0.0.

Rails Link_to Method Delete Not Working

All the includes were set correctly. Now the javascript has been moved out of the link, and into external js files. Here is my code - View <%= link_to 'Delete User?', child, :confirm => "Are you sure you want to delete #{child.full_name}?", :method => :delete, :class => "user-additional", :style => "font-size:12px;font-weight:normal;" %> Try using this code instead: <%= link_to 'Kill Flea', [flea.dog, flea], :confirm => 'Sure?', :method => :delete %> share|improve this answer answered Dec 3 '10 at 3:07 Sam Ritchie 9,14323050

In reading similar issues I have learned that the Delete must be converted to a POST for the browser to interpret it. Has anyone figured out how to reenable the token? If you're not including this in your layout with this line: <%= javascript_include_tag "application" %> Then both the jquery.js and jquery_ujs.js files won't be included, and so the :method => :delete Rails Delete Link Goes To Show When I put the link to defaults after my link to jquery, the problem went away and it all started working properly. 19 Reply by tuscanidream 2011-02-16 16:36:30 tuscanidream From: Rhode

Why is looping over find's output bad practice? Rails 4 Link_to Method Delete Not Working GO OUT AND VOTE Very small transformer powering a microwave oven Can anybody advise what type of connector this is? more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed Visit Website Browse other questions tagged ruby-on-rails routing rails-routing or ask your own question.

These two files are typically included in the app/assets/javascripts/application.js file, which contains this content: //= require jquery //= require jquery_ujs //= require_tree . Link_to Delete Not Working I'm using Rails 3.1. So, back in your controller's destroy action, it tries to 'redirect_back_or' which results in GET current_url. Rails do a trick to make it delete ( I guess by inserting _method = delete if i remember correctly ) share|improve this answer answered Aug 3 '11 at 23:11 mkk

Rails 4 Link_to Method Delete Not Working

What I done is I changed the link_to "Logout", destroy_user_session_path, :method => :delete to form_tag destroy_user_session_path, :method => :delete, :id => "logout_form" link_to 'Logout', "#delete", :onclick => "$('#logout_form').submit();" Now its working pop over to these guys I didt said that this is 100 % answer . Rails Link_to Method Delete Not Working I verified in Hartl's source code that he defines a "destroy" method in the controller, not "delete". Rails Destroy Not Working If I write <%= link_to 'Test', '/', :method => :delete %>, Rails will turn that into Test</a>.

Why is translateY(-50%) needed to center an element which is at top: 50%? this contact form stackoverflow.com/questions/9950332/… –jay Mar 30 '12 at 21:00 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign Can anybody advise what type of connector this is? Whereas this: <%= button_to "delete", @note, :method => :delete, :confirm => "Are you sure" %> Does route properly. Rails Link_to Destroy Path

  • ruby 2.2.4p230 (2015-12-16 revision 53155) [x64-mingw32] B.
  • As you probably know, if you would not specify :method => :delete, then according to REST, you would be redirected into show action.
  • it's as if it's using GET on /dogs/1/fleas/7 instead of DELETE?!?
  • Dealing With Dragonslayers My boss asks me to stop writing small functions and do everything in the same loop Isn't the BBC being extremely irresponsible in describing how to authenticate an
  • Boss just quit leaving behind a toxic workplace.
  • The delete link is using GET http verb even though you used method: delete in your link.
  • Taking Control Back as a DM?
  • share|improve this answer answered Mar 21 '14 at 10:31 Sithara Suresh 539412 add a comment| up vote 1 down vote Also if you get this problem in production mode, it may
  • If this doesn't work either, you should post the server logs. –Agis Oct 21 '12 at 12:22 still not working...

Cypher Aug 3 '11 at 23:17 It could follow it, and it'll just be a GET method request. current community chat Stack Overflow Meta Stack Overflow your communities Sign up or log in to customize your list. Making A Solid Mesh Melt? http://elliottwaveresearch.com/not-working/delete-key-not-working-mac.html share|improve this answer answered Aug 3 '11 at 23:06 coreyward 36.9k979109 add a comment| up vote 0 down vote I think that the answer to your question is that jQuery messes

If jQuery and prototype JS libs are being used, try using only prototype? –Zabba Jan 5 '11 at 17:35 Probably you have wrong link to script file in head Rails Data-method Delete Not Working How? more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed

See http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets share|improve this answer answered Mar 28 '14 at 13:57 ReggieB 3,84822326 That is the real reason, it is the command: RAILS_ENV=production bin/rake assets:precompile –shontauro Apr 2 '15

But combining things so far like the following gives no errors but I still have no binding.pry from the destroy method in the controller. <%= link_to 'Destroy', [comment.post, comment], method: :delete, And who are »they«? How can I safely handle a concentrated (fuming) nitric acid spill? No Route Matches [delete] My cat sat on my laptop, now the right side of my keyboard types the wrong characters What power do I have as a driver if my interstate route is blocked

How to prove that authentication system works, and that the customer is using the wrong password? csrf_meta_tag is somewhat explained here. the link doesn't seem to work... –fxuser Oct 21 '12 at 11:36 add a comment| up vote 1 down vote This is the Rails way: <%= link_to 'Destroy', post, confirm: 'Are Check This Out Cypher Aug 3 '11 at 22:57 Nope, button_to is working though so I'll probably just go forward with that as it's safer like you suggested below. –Kombo Aug 3

Quine Anagrams! (Cops' Thread) Why (and when) does pattern matching with f[__] perform MUCH more quickly than _f? For some reason, I have an older app on which these link_to links work, but I can't remember why.. thanks! –fxuser Oct 21 '12 at 14:35 add a comment| 6 Answers 6 active oldest votes up vote 6 down vote You must be add //= require jquery //= require jquery_ujs Make sure you have this in your layout: <%= javascript_include_tag :all %> If you do have this, there might be deeper problems keeping your javascript from running, but this is the

CAN'T USE BOTH BECAUSE THEY CONFLICT!! Does that 'switch on' the attributes like "data-confirm"? ############################################If i've helped you then please recommend me at Working With Rails:#http://www.workingwithrails.com/person/ … i-williams 12 Reply by webdevotion 2010-04-19 11:44:52 webdevotion Registered: 2007-02-21 Browse other questions tagged jquery ruby-on-rails ruby-on-rails-3 or ask your own question. Did I cheat?

UPDATE: Change your action to: def destroy @post = Post.find(params[:id]) respond_to do |format| if @post.destroy format.html { redirect_to posts_url } format.json { head :no_content } else format.html # do something here Build me a brick wall!