Replace a form_for and f.submit with a link_to

I have a helper which puts a form_for in the view (from holding it in an
ERB tag). It looks like this;{
<% form_for(following, :url => user_follower_path(followee, follower))
do |f| %>
<%= f.hidden_field :status, :value => 0 %>
<%= f.submit ‘Block’, :class => “bar_button block_button” %>
<% end %>

I want to replace this with a link_to, but I don’t know if a link_to
could handle the status change that is sent (using the hidden_field tag)
through the form_for. This example doesn’t work, but I was wondering if
someone knows how I can achieve something similar(?);

“#{link_to “Block”, {:controller => “followers”, :action => “update”,
:user_id => followee, :id => follower, :status => 0}, :confirm => “Are
you sure?”, :class => “bar_button block_button”}”

Another option is to keep the form_for but to use a link_to to perform
the submit on the form. Essentially, we’re trying to avoid having an
input element in the DOM - we just want a simple anchor tag. Is this

first, put html element id using :html

like this:

<% form_for(following, :url => user_follower_path(followee,
follower), :html => {:id => “my_form”}) do |f| %>

and use below code in block.

<%= link_to_function “submit”,
“javascript:document.getElementById(“my_form”).submit(); return
false” %>

it’s old trick so work very well.

On 2008ë…„7ì›”11일, ì˜¤ì „4ì‹œ26분, Neil C. <rails-mailing-l…@andreas-

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs