2011-05-17 36 views
0

我有一個模型:ThreadParticipation如何建立一個remote_to鏈接,並通過設置了一個param

我想建立一個發送ThreadParticipation.id和PARAM隱藏== true的鏈接。

我該如何建立一個鏈接來做到這一點?

ThreadParticipation控制器:

def hide 
    @record = ThreadParticipation.find(params[:id) 
    @record.hide == params[:hide] 
    @record.save 
end 

查看:

<%= link_to "hide", '/thread/:id/thread_participations/:id/hide', :remote => true %> 

是否正確?如何通過link_to(hide == true)傳遞一個參數?有任何想法嗎?

感謝

回答

2

你可以試試這個

<%= link_to "hide", "/thread/#{thread_id}/thread_participations/#{id}/hide?hide=true", :remote => true %> 

或者更好的是,確定的路線來獲得/線程/:thread_id單/ thread_participation /:ID部分。讓我們說的路線是hide_thead_pariticipation_thread_path

<%= link_to "hide", hide_thread_participation_path(thread_id,:hide => true), :remote => true %> 

而且控制器代碼好像是用 「@ record.hide == PARAMS [:隱藏]」。也許它只是一個=在那裏?

相關問題