开发者

Using a normal text link instead of a form

I am writing a small application using Rails 3. In one part of it there is a link (should be a link) that if clicked adds a connection between two people (see below).

What I am really needing is to use a normal text link instead of a form, how is this done?

<%= form_for([@profile, @contact]) do |f| %>

    <p><%= f.hidden_field :profile_id, :value => params[:profile_id] %></p>
    <p><%= f.hidden_field :friend_id, :value => profile.id %></p>

 开发者_运维百科   <p><%= f.submit %></p>

<% end %>


Something like:

<%= link_to 'link these persons', [@profile, @contact], :method => :post, :profile_id => params[:profile_id], :friend_id => profile.id %>


You can try sumbitting the form with javascript like this:

<%= link_to 'Submit', "#", :onclick=>"('form_id').submit()"%>

This will submit your form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜