简体   繁体   English

Ruby on Rails link_to未定义的方法

[英]Ruby on Rails link_to undefined method

I'm following the Twitter for Zombies tutorial and i'm having trouble getting the link_to method to work. 我正在关注僵尸推特(Twitter for Zombies)教程,但无法使link_to方法起作用。

In my Tweet controller I have: 在我的Tweet控制器中,我有:

@tweet = tweet.find(params['id']);

In my view i've tried the following: 在我看来,我尝试了以下方法:

<%= link_to @tweet.zombie.name, @tweet.zombie %>
<%= link_to @tweet.zombie.name, zombie_path(@tweet.zombie) %>

But I keep getting the error: 但我不断收到错误:

undefined method `zombie_path' for #<#<Class:0xab1fd00>:0xa1d5d80>

Any ideas whats up with this? 有什么想法吗? Thanks. 谢谢。

What's in your routes.rb file? 您的routes.rb文件中有什么? Please show us. 请给我们看看。

Do you have the line like this? 你有这样的台词吗?

resources :zombies

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM