2012-03-06 129 views
-1

我對RoR完全陌生。我現在在控制器的一個視圖中有一個參數,我怎樣才能在同一個控制器的另一個視圖中獲取它?在另一個視圖中獲取一個視圖的參數

+4

請將您能有所幫助發佈相關的控制器代碼並在兩個操作中指出你想要的參數。 – 2012-03-06 08:09:54

回答

-1

我批准你閱讀ruby on rails guides

閱讀入門章節,然後創建博客應用程序,你會看到 ,給你一個很大的entrace到Ruby on Rails的。嘗試瞭解Rails的方式。

+1

這個問題並不完全清楚,所以我不確定如何將海報引用到Rails指南的主頁上會有所幫助。這也是違背實踐的,只是鏈接到外部網站作爲答案。 – 2012-03-06 08:20:57

3

您可以在form-a中設置表單或link_to,並將HTTP(POST/GET)設置爲form-b​​。請記住,您可以將任何HTML(或JS)放入您喜歡的視圖中。

看一看:

link_to

link_to "Profile", :controller => "profiles", :action => "show", :id => @profile 
# => <a href="/profiles/show/1">Profile</a> 

如果你想鏈接到相關的表,你可以容易做到這一點:

# @person.company.name is the name of the link 
# company_path(@person.company) is the associated model 
<%= link_to @person.company.name, company_path(@person.company) %> 
相關問題