Hello people I''m stuck in a problem, I''ve tried to solve this from last week and I still can''t achieve it. I have a Form in my rails 3.0.9 app to "accept" or "reject" a document, untill now I''m using a collection select with two options "Accept" and "Reject", then I have to click on the submit button to save changes. What I want to do now is, instead of the collection select I want to have two buttons, one named "accept" and the other named "reject" and when the user click one of the buttons, save the changes inmediately. Does anyone know how can I do this?? (I''ve tried with "button_to", but I don''t know how to change the value of the attribute). Thanks -- 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.
Maybe you should try pure html button with onclick attribute that sends some information to your controller (via ajax?). It''s quite simple btw. On 27 окт, 20:23, Angelo Cordova <acord...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello people > > I''m stuck in a problem, I''ve tried to solve this from last week and I > still can''t achieve it. > > I have a Form in my rails 3.0.9 app to "accept" or "reject" a > document, untill now I''m using a collection select with two options > "Accept" and "Reject", then I have to click on the submit button to > save changes. > > What I want to do now is, instead of the collection select I want to > have two buttons, one named "accept" and the other named "reject" and > when the user click one of the buttons, save the changes inmediately. > > Does anyone know how can I do this?? (I''ve tried with "button_to", but > I don''t know how to change the value of the attribute). Thanks-- 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.
On Thu, Oct 27, 2011 at 6:23 PM, Angelo Cordova <acordinz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello people > > I''m stuck in a problem, I''ve tried to solve this from last week and I > still can''t achieve it. > > I have a Form in my rails 3.0.9 app to "accept" or "reject" a > document, untill now I''m using a collection select with two options > "Accept" and "Reject", then I have to click on the submit button to > save changes. > > What I want to do now is, instead of the collection select I want to > have two buttons, one named "accept" and the other named "reject" and > when the user click one of the buttons, save the changes inmediately. > > Does anyone know how can I do this?? (I''ve tried with "button_to", but > I don''t know how to change the value of the attribute). Thanks >In the Form, you can set two buttons with a different text Accept Reject I presume that could be submit_tag("Accept") submit_tag("Reject") with the appropriate html around it. Then when the user clicks one of the two buttons, you will get a POST request that will contain params and one of the params will have the key "commit" Parameters: {"utf8"=>"✓", "authenticity_token"=>"eW3HL1vjUzTcqpFvDcXnu9rGGUhFFe6vcwqfaA/4nWE=", "user"=>{"first_name"=>"Peter", "last_name"=>"V",.. }, "commit"=>"Accept"} So in the action if you can check params[:commit] which should be either "Accept" or "Reject" and can use that for your logic. as in case params[:commit] when "Accept" # do the accept when "Reject" # do the reject else # should not occur (but it can in certain circumstances) end HTH, Peter -- 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.
Thanks for your help Peter You were right, I tried what you told me, and everything worked perfect Thanks again for your help On 27 oct, 14:30, Peter Vandenabeele <pe...-jNuWw7i2w7syMbTcgqFhxg@public.gmane.org> wrote:> On Thu, Oct 27, 2011 at 6:23 PM, Angelo Cordova <acord...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello people > > > I''m stuck in a problem, I''ve tried to solve this from last week and I > > still can''t achieve it. > > > I have a Form in my rails 3.0.9 app to "accept" or "reject" a > > document, untill now I''m using a collection select with two options > > "Accept" and "Reject", then I have to click on the submit button to > > save changes. > > > What I want to do now is, instead of the collection select I want to > > have two buttons, one named "accept" and the other named "reject" and > > when the user click one of the buttons, save the changes inmediately. > > > Does anyone know how can I do this?? (I''ve tried with "button_to", but > > I don''t know how to change the value of the attribute). Thanks > > In the Form, you can set two buttons with a different text > > Accept > Reject > > I presume that could be > > submit_tag("Accept") > submit_tag("Reject") > > with the appropriate html around it. > > Then when the user clicks one of the two buttons, you will get a POST > request that will contain params and one of the params will have the key > "commit" > > Parameters: {"utf8"=>"✓", > "authenticity_token"=>"eW3HL1vjUzTcqpFvDcXnu9rGGUhFFe6vcwqfaA/4nWE=", > "user"=>{"first_name"=>"Peter", "last_name"=>"V",.. }, "commit"=>"Accept"} > > So in the action if you can check > > params[:commit] > > which should be either "Accept" or "Reject" and can use that for your logic. > > as in > > case params[:commit] > when "Accept" > # do the accept > when "Reject" > # do the reject > else > # should not occur (but it can in certain circumstances) > end > > HTH, > > Peter-- 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.