传递 link_to 的变量 ID 时出现此错误。我无法读取下一页中的变量 (blog_details.html.erb)
错误:
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>
有人可以帮我解决这个错误吗?