Alpha Blue you GOT it!! Thanks!!  Here was my 'index' code before:
<% @projects.each do |projects| %>
  <tr>
    <td><%= link_to projects.name, :controller => 'myproject', :action
=> 'show', :id => current_user.projects.id %></td>
    <td><%= link_to 'Edit', :controller => 'myproject', :action =>
'edit', :id => current_user.projects.id  %></td>
    <td><%= link_to 'Delete', projects, :confirm => 'Are you
sure?', :method => :delete %></td>
  </tr>
<% end %>

After I changed the :id assignment from 'current_user.projects.id' to
just 'projects.id' the correct id number was getting assigned (i.e.
the 'show' & 'edit' references in the 'view page source' now matched
the delete index number):
  <tr>
    <td><a href="/myproject/show/13">Wash Dawgs</a></td>
    <td><a href="/myproject/edit/13">Edit</a></td>
    <td><a href="/projects/13" onclick="if (confirm('Are you sure?'))
(DELETED EXTRA CODE HERE)
  </tr>

THANKS EVERYONE!  THIS NEWBIE GREATLY APPRECIATES YOUR INPUT!!!



On Jan 26, 1:33 pm, Alpha Blue <li...@ruby-forum.com> wrote:
> Souschef wrote:
> > Interesting Alpha Blue, it does look like that.  Where might I be mis-
> > referncing the object other than the myproject controller?
>
> It can be an easy mistake to miss.
>
> I found an old cart model a long time ago and for some strange reason, I
> saved it because it had this particular issue you are having.
>
> cart.items.each_with_index do |item, index|
>   item_id = Product.find_by_title(item.title)
>   values.merge!({
>       "amount_#{index+1}" => item.price,
>       "item_name_#{index+1}" => item.title,
>       "item_number_#{index+1}" => item_id,
>       "quantity_#{index+1}" => item.quantity
>     })
> end
>
> In this example, notice the item_id?  It was referencing the object_id
> instead of the id field.  When I changed it to:
>
> cart.items.each_with_index do |item, index|
>   item_id = Product.find_by_title(item.title)
>   values.merge!({
>       "amount_#{index+1}" => item.price,
>       "item_name_#{index+1}" => item.title,
>       "item_number_#{index+1}" => item_id.id,
>       "quantity_#{index+1}" => item.quantity
>     })
> end
>
> .. it referenced the correct id.  Keep in mind, this is a really old
> example and was something someone else built.
>
> But, I would check anything in your controller or model that is
> referencing name_id instead of name.id and do some troubleshooting in
> your rails console since you haven't setup any test code for yourself.
>
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to