Forum: Ruby on Rails Rails + jQuery and Links

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
sshefer (Guest)
on 2008-12-16 11:26
(Received via mailing list)

I currently have a "save for later" function that effectively allows a
logged in user to save an position for later viewing.  (Similar to the
watch/unwatch function on github).  In my scenario I have a Position
model.  Saved positions are resources that belong to the Position,
using the current_user before creation or deletion to create that user

To do this I am doing a POST directly using the link:

<%= link_to('Save for Later',
        :method => :post, :class => "new_saved_position")-%>

However, in my application.js my code seems to still submit the link
and ignore the "return false;" at the end.

    type: "POST",
    url: $(this).href,
      dataType: "script",
      beforeSend: function(xhr) {xhr.setRequestHeader("Accept", "text/
    return false;

My question:

By adding ":method => :post" am I altering/tainting the way this
should be done?  I realize that having a direct POST like this is not
Restful - are there better ways of doing this?  While not the topic of
this board - is my jQuery code wrong?

This topic is locked and can not be replied to.