我正在传递id
fromlink_to
到locals
。但它无法找到结果,说cannot find article without id
。我需要传递 id 以articles
在模态中显示。
<% @articles.each do |a|%>
<p>
<%= link_to a.title, {"data-toggle" => "modal", "data-target" => '#myModal', :id => a.id}%>
</p>
<% end %>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria labelledby="myModalLabel" aria-hidden="true">
<%= render :partial => "site#show", :locals => {@article => Article.find(params[:id])}%>
</div>
在控制器中
def home
@articles = Article.order("created_at DESC").limit(5)
@videos = Video.order("created_at DESC").limit(5)
end
我从控制器获取 id。这不是零。事情是我能够在其中找到文章block
但无法将其发送给当地人。