HI all, I have an index page in my site and each item displayed from the model has a link (that looks like a button)... I want that link to simply clear a field (or set it to some value) in the underlying model for that entry... The page does not have a form on it and i''d like to avoid that if possible.... seems i should be able to select the link and have it process an update on the item behind the scenes and then re-display the page (or if i get fancier later - use ajax to red-display the item?)... I hope this makes sense... i''m obviously new to web dev AND rails... 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.
On Thu, Oct 27, 2011 at 16:32, Max <aamax-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org> wrote:> seems i should be able to select the link and have it process an > update on the item behind the scenes and then re-display the page (or > if i get fancier later - use ajax to red-display the item?)...You''re right, you don''t need a form to process anything. What springs to my mind offhand is to have the link send an AJAX request to the server, to clear/set the field in question, and when you get back the confirmation, show it on the screen as cleared/set. (Most likely by getting back the data for the new value of the whole item, and updating the item''s representation on the view.) -Dave -- LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages. Where: Northern Virginia, Washington DC (near Orange Line), and remote work. See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence). Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson) -- 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.
On 27 October 2011 21:32, Max <aamax-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org> wrote:> HI all, > > I have an index page in my site and each item displayed from the model > has a link (that looks like a button)... I want that link to simply > clear a field (or set it to some value) in the underlying model for > that entry... The page does not have a form on it and i''d like to > avoid that if possible.... > > seems i should be able to select the link and have it process an > update on the item behind the scenes and then re-display the page (or > if i get fancier later - use ajax to red-display the item?)... > > I hope this makes sense... i''m obviously new to web dev AND rails...A simple way, avoiding AJAX and so on until you have more experience, is to have an empty form with just the submit button. To the user it will just look like a button but Rails will do all the clever stuff for you. You just need to provide the action and (if appropriate) re-display the same view. 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Oct 27, 2011 at 1:32 PM, Max <aamax-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org> wrote:> I have an index page in my site and each item displayed from the model > has a link (that looks like a button)... I want that link to simply > clear a field (or set it to some value) in the underlying model for > that entry...Uh, realizing that every time a spider comes along to index your site, every one of those links will be activated? (unless the page in question is password protected)> The page does not have a form on it and i''d like to avoid that if possible....Google ''http idempotent request'' to understand why you should use a POST rather than GET for actions that change data. HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- 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.