靜態控制器從同一領域抓取屬性:使用相同的字段的ID
def show
@product = ProductAttribute.where('value = ?', helpers.value_check(:prod_id))
end
module StaticsHelper
def value_check(id)
@product = Product.find_by(id: id)
return @product.value
end
end
我試圖獲取從產品模型的數值屬性。此值屬性是模型「產品」和「產品屬性」之間使用的主鍵。
index.html.erb靜態視圖的:
<% @products.each do |product| %>
<li>
<%=link_to product.name, statics_show_path(prod_id: product.id)%>
</li>
<% end %>
<%= link_to "New Product", statics_new_path %>'
我在做什麼錯?
你能發佈錯誤嗎? –