2015-09-14 76 views
0

如何發送其他參數以及ID?傳遞參數連同ID

歷史控制器

def edit 
    @histories = History.find(params[:id]) 
    end 

    def update 
    @histories = History.find(params[:id]) 
    @histories.projects_lkp_id = params[:projects_lkps_id] 
    respond_to do |format| 
     if @histories.update(history_params) 
     format.html{ redirect_to histories_path(id: @histories.id), notice: "History updated successfully" } 
     else 
     format.html{ render 'edit' } 
     end 
    end 
    end 

歷史/視圖/索引

<% @histories.each do |d| %> 
    <% d.pictures.each do |sAV| %> 
     <div><%= d.past %> 
      <%= link_to content_tag(:span, '', class: 'glyphicon glyphicon-pencil btn-xs'), edit_history_path(d) %></div> 
      <div class='col-md-4 col-sm-5'> <%=image_tag sAV.pic (:medium) %> </div> 
    <% end %> 
    <% end %> 

我需要發送到projects_lkps_id與此線<%= link_to content_tag(:span, '', class: 'glyphicon glyphicon-pencil btn-xs'), edit_history_path(d) %></div>

回答

1
<%= link_to content_tag(:span, '', class: 'glyphicon glyphicon-pencil btn-xs'), edit_history_path(d, projects_lkps_id: d.projects_lkp_id) %> 
1

你可以試試這個。

<%= link_to edit_history_path(d, projects_lkps_id: d.projects_lkp_id) do %> 
    <span class='glyphicon glyphicon-pencil btn-xs'></span> 
<% end %>