我正在尝试显示一个页面,显示喜欢微博的用户。我希望 Uri 是 localhost:3000/microposts/someid#/into_it。似乎通过路径没有响应控制器?
我在 view/microposts/_micropost.html.erb 文件中链接到此页面:
<%= link_to micropost.votes_for, into_it_micropost_path(@micropost) %>
由于此路径,我在浏览器中收到以下错误并且页面未加载:
No route matches {:action=>"into_it", :controller=>"microposts", :id=>nil}
在我的微帖子控制器中:
def into_it #for the view; displays who likes the post
@title = "Into_it!"
@micropost = Micropost.find(params[:id])
render 'show_users_into_it'
end
micropost/show_users_into_it 当前是一个空白文件
路由文件:
resources :microposts, only: [:create, :destroy, :into_it] do
member do
get :into_it
end
end
在耙式路线中,我有:
into_it_micropost GET /microposts/:id/into_it(.:format) microposts#into_it