傳遞link_to的變量ID時出現此錯誤。我無法讀取該變量在接下來的頁面(blog_details.html.erb)無法通過鏈接傳遞ID
錯誤:
ActiveRecord::RecordNotFound in HomeController#blog_details
Couldn't find Post without an ID
我的家控制器:
class HomeController < ApplicationController
def blog
@posts = Post.all
end
def blog_details
@post = Post.find(params[:id])
end
end
我與變量鏈接:
<div class="post-title">
<h2 class="title">
<%= link_to (post.titulo), :controller => 'home',
:action => 'blog_details', :post_id => post.id %>
</h2>
</div>
有人可以幫我解決這個錯誤嗎?
謝謝你。工作 – user1211674 2013-03-03 18:47:59