现在我有一个像这样的表单视图
<%=form_for(([@community, @comment]), :remote => true, :class => 'form' ) do |f| %>
<%= f.text_field :body, :id => "body", :class => "chat" %>
<button type="submit" class="btn">submit</button>
<% end %>
<% @comments.each do |comment| %>
Request to <%= request(@community, comment.user) %> <br />
<% end %>
然后佣金路线显示此
POST /communities/:community_id/comments(.:format) comments#create
application_helper 的编码方式如下。我不知道在create_community_comment_path(????????)
内放置什么也不是正确的路径。
def request(community, user)
if user
nickname = user.profile.try(:nickname)
body = "You've got a request from " + nickname
link_to "<span class='btn'>request</span>".html_safe , create_community_comment_path(community, body),{:method => :post}
end
end
有人能告诉我如何让link_to
将固定的参数传递给表格吗?
答案 0 :(得分:2)
试试这个
link_to "<span class='btn'>request</span>".html_safe , create_community_comment_path(community, body, :parm1=>"Valu1", :parm2=>"Valu2"),{:method => :post}