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@googlegroups.com.
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.

Search Discussions

  • Dave Aronson at Oct 27, 2011 at 8:53 pm

    On Thu, Oct 27, 2011 at 16:32, Max 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@googlegroups.com.
    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 at Oct 27, 2011 at 8:57 pm

    On 27 October 2011 21:32, Max 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@googlegroups.com.
    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.
  • Hassan Schroeder at Oct 27, 2011 at 9:18 pm

    On Thu, Oct 27, 2011 at 1:32 PM, Max 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@gmail.com
    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@googlegroups.com.
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedOct 27, '11 at 8:33p
activeOct 27, '11 at 9:18p
posts4
users4
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase