Forum: Ruby on Rails i need to link an item in the 'yield'

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
3e1864d1ff9550d6aea75e7e6e496a52?d=identicon&s=25 nubyonrails37 (Guest)
on 2007-04-05 23:07
(Received via mailing list)
Code below displays pitchers attached to a given scoreboard -- but i
want to be able to edit the pitchers using this page to click 'edit'
from.  Is there a way i can have the pitcher's name be a hyperlink,
and i need the to tell the app which pitcher to edit.

When i run the below as is...  my 'Edit' link looks like
http://localhost:3000/pitchers/edit/666... but there's no pitcher with
an id of 666 -- which is the game id -- and it returns the error
'Couldn't find Pitcher with ID=666'

the code in question is this:
<%= link_to 'Edit', :controller => 'pitchers', :action => 'edit', :id
=> @pitcher %>

Any help is appreciated.


<% for column in Scoreboard.content_columns %>
  <b><%= column.human_name %>:</b> <%=h @scoreboard.send(
<% end %>

<%= link_to 'Edit', :action => 'edit', :id => @scoreboard %> |
<%= link_to 'Back', :action => 'list' %>
<% for pitcher in @scoreboard.pitchers %>
  <table width="70%" border="0">
      <td width="230"><div align="left"><%= pitcher.flname %> (<%= %>) <%= link_to 'Edit', :controller =>
'pitchers', :action => 'edit', :id => @pitcher %></div></td>
      <td><div align="left"><strong>IP</strong>: <%= pitcher.innp %></
      <td><div align="center"><strong>R</strong>: <%= pitcher.runs %></
      <td><div align="center"><strong>H</strong>: <%= pitcher.hits %></
      <td><div align="center"><strong>E</strong>: <%= pitcher.eruns %></
      <td><div align="center"><strong>W</strong>: <%= pitcher.bballs
      <td><div align="center"><strong>K</strong>: <%= pitcher.Ks %></
      <td><div align="center"><strong>HR</strong>: <%= pitcher.HRs %></
      <td><div align="center"><strong>ERA</strong>: <%= pitcher.ERA %></
  <hr />
<% end %>

<%= form_tag :action => "pitcher", :id => @scoreboard %>
  <%= text_field "pitcher", "flname" %><br/>
  <%= submit_tag "Add Pitcher!"%>
3e1864d1ff9550d6aea75e7e6e496a52?d=identicon&s=25 nubyonrails37 (Guest)
on 2007-04-06 02:31
(Received via mailing list)

this works like i want....

<td width="230"><div align="left"><%= pitcher.flname %> (<%= %>) <%= link_to 'Edit', :controller =>
'pitchers', :action => 'edit', :id => %></div></td>

I'm 37 and I can read at a 2nd grade level.. :)

This topic is locked and can not be replied to.