希望標題有一定意義,但我會進入更多細節。我有一個簡單的應用程序,允許用戶上傳食譜。然後,您可以查看所有這些或單獨查看每個配方通過show動作顯示與正在顯示頁面上顯示的另一個對象相似的對象
def show
@recipe = Recipe.find(params[:id])
end
在視圖然後我顯示該食譜的各種屬性,像這樣
<b><%= @recipe.dish_name %></b><br>
<b><%= image_tag @recipe.avatar.url(:showrecipe) %><b><br>
<b>by <%= @recipe.user.name %></b></br></br>
<b>Description</b></br>
<b><%= @recipe.description %></b></br>
<b>Ingredients</b></br>
<b><%= raw(ingredient_names_list(@recipe.ingredients)) %></b>
<br>
<b>Preperation Steps</b></br>
<ol>
<li><%= raw(preperation_steps_list(@recipe.preperations)) %></li>
</ol>
我想達成什麼是在同一頁上有一個部分,將列出其他食譜的名稱,這些食譜就像顯示食譜一樣,基於dish_name
這是我第一次做這樣的事情,所以我正在尋找一些指向什麼資源看看或如何去一個布特這個
我的想法到目前爲止是
1)創建調用基礎上,dish_name一個範圍的方法顯示,經過dish_name的PARAMS。
這可能是錯誤的,只是爲了尋找在正確的方向輕推,請
編輯
我自己也嘗試這在我的表演動作,但我得到錯誤的參數數目(1 0)
@relatedrecipe = Recipe.where(@recipe.dish_name('LIKE'),(params[:dish_name]))
感謝
感謝您的建議,我已閱讀,但它沒有處理相關的模型?是對的嗎? – Richlewis
啊我的錯誤似乎有一種叫multi_solr_search的方法 – Richlewis
你介意給我一個例子讓我開始請嗎?感謝您的幫助 – Richlewis