views:

17

answers:

1

I'm listing the data from one of my models in a table

<% @events.each do |event| %>
  <tr>
<td align="center"><%= button_to "Add", :controller => 'personal', :action => "add" %> </td>
<td><%=h event.name %></td>
<td><%=h event.description %></td>
 <td><%= link_to 'Show', event %></td>
<td><%= link_to 'Edit', event %></td>

<% end %>

Each row of the table list an different event with name and description information from the @events object. I'm trying to make button the performs some actions based on the row of whatever event is clicked, but I cant figure out how to pull the parameters. i.e. if the "Add" button is clicked for event #3 , then in the action being able to call

@event = Event.find(params[:id])

Its throwing up an initialized constant error. Whats bothering me is somehow the show, and edit actions can pull whatever event it is and display its information (it was generated through scaffold) but the custom action I created doesnt seem to be able to do so.

Is problem that the action is in a different controller? I tried adding it to the event_controller but still nothing.

So how can I query this record in the model and play around with it?

+1  A: 

Change the line where you specify button_to, i.e.

<%= button_to "Add", {:controller => 'personal', 
                          :action => "add", :id => event.id} %>
KandadaBoggu
thanks soo much man, youve helped me like 3 times today
ChrisWesAllen