简体   繁体   中英

undefined method `user_path' error

_app_views_pins__pin_html_erb__600263857_22928508 app/views/pins/_pin.html.erb

3     <p class="description">
4         <%= pin.description %>
5     </p>
6     <p>
7         <strong>
8             Posted by <%= link_to pin.user.name, pin.user %>
9         </strong>
10     </p>
11     <% if current_user == pin.user %>
12        <p>
13            <%= link_to 'Edit', edit_pin_path(pin) %>

Line 8 is the problem. Would be grateful for any suggestions. Thanks a lot!

The error is stating that pin.user isn't a route. The link_to helper requires a valid route.

Run rake routes to see which routes are available. Also, check out Rails Guides to become more familiar with Rails routing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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