Bob Smith
2012-Feb-24 20:44 UTC
How do I make a delete button that doesn''t go to another page?
I''m trying to make a delete button for child objects. When the button is pressed, I want the view to stay the same to protect whatever data the user has entered already. When the button is pressed, it should prompt "Are you sure?" and get an answer. I have most of this set already, but I can''t find a way to keep things from leaving the view. Here''s my code controller> def destroy person = Person.find(params[:id]) person.destroy redirect_to(households_url) ---problem here, but I have no idea what to put in it''s place end view> <td><% if !person_form.object.new_record? %> <%= person_form.hidden_field :id, :index => nil %> <%= link_to ''Delete'', person_path(person.id), :confirm => ''Are you sure?'', :method => :delete %> <% end %></td> By the way, I''m running Rails 2.3.9 at the moment. Thanks Bob <bsm2th-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> -- 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.
Dave Aronson
2012-Feb-24 20:53 UTC
Re: How do I make a delete button that doesn''t go to another page?
On Fri, Feb 24, 2012 at 15:44, Bob Smith <bsm2th-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m trying to make a delete button for child objects. When the button > is pressed, I want the view to stay the same to protect whatever data > the user has entered already.Have you considered making it an AJAX call? -Dave -- Dave Aronson: Available Cleared Ruby on Rails Freelancer (NoVa/DC/Remote) -- see www.DaveAronson.com, and blogs at www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.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.
Bob Smith
2012-Feb-24 20:58 UTC
Re: How do I make a delete button that doesn''t go to another page?
On Feb 24, 3:53 pm, Dave Aronson <googlegroups2d...-BRiZGj7G2yRXqviUI+FSNg@public.gmane.org> wrote:> On Fri, Feb 24, 2012 at 15:44, Bob Smith <bsm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''m trying to make a delete button for child objects. When the button > > is pressed, I want the view to stay the same to protect whatever data > > the user has entered already. > > Have you considered making it an AJAX call? > > -Dave > > -- > Dave Aronson: Available Cleared Ruby on Rails Freelancer > (NoVa/DC/Remote) -- seewww.DaveAronson.com, and blogs atwww.Codosaur.us,www.Dare2XL.com,www.RecruitingRants.comLove to. Could you send me an example to start with? Bob -- 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.
Dave Aronson
2012-Feb-24 21:44 UTC
Re: Re: How do I make a delete button that doesn''t go to another page?
On Fri, Feb 24, 2012 at 15:58, Bob Smith <bsm2th-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Dave Aronson <googlegroups2d...-BRiZGj7G2yRXqviUI+FSNg@public.gmane.org> wrote:>> Have you considered making it an AJAX call?> Love to. Could you send me an example to start with?Better than an example would be a tutorial, like: http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ :-) -Dave -- Dave Aronson: Available Cleared Ruby on Rails Freelancer (NoVa/DC/Remote) -- see www.DaveAronson.com, and blogs at www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.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.
Kevin Bedell
2012-Feb-24 22:00 UTC
Re: Re: How do I make a delete button that doesn''t go to another page?
Here''s a good primer on how to do ajax calls using JQuery. These are the skills you need to do this kind of work. http://railscasts.com/episodes/136-jquery The only thing different is I''d recommend writing the javascript in coffeescript instead. -Kevin On Fri, Feb 24, 2012 at 4:44 PM, Dave Aronson <googlegroups2dave-BRiZGj7G2yRXqviUI+FSNg@public.gmane.org> wrote:> On Fri, Feb 24, 2012 at 15:58, Bob Smith <bsm2th-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Dave Aronson <googlegroups2d...-BRiZGj7G2yRXqviUI+FSNg@public.gmane.org> wrote: > >>> Have you considered making it an AJAX call? > >> Love to. Could you send me an example to start with? > > Better than an example would be a tutorial, like: > > http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ > > :-) > > -Dave > > -- > Dave Aronson: Available Cleared Ruby on Rails Freelancer > (NoVa/DC/Remote) -- see www.DaveAronson.com, and blogs at > www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.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.