我试图显示一个页面,显示喜欢微博的用户。我想让Uri成为localhost:3000/microposts/someid#/ into_it。通过路径似乎没有响应控制器?控制器未收到ID参数
我和网页链接在一个视图/微柱/ _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
微柱/ show_users_into_it是一个空白文件c urrently
routes文件:
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
你说我应该的link_to @micropost。 votes_for? – Jaqx
不,他是说,如果@micropost是新记录,你应该隐藏这个链接 – Phobos98
这不是一个新记录。我只想找到喜欢现有微博记录并显示用户的用户 – Jaqx