hello, everyone.
I''m studying rails with version 2.3.5, but I got a problem just now.
I wrote code like:
<td><%= link_to ''Delete'', :action =>
''remove_from_cart'', :id =>
cart_item %></td>
and I write that method like this.
def remove_from_cart
@cart = find_cart
remove_item = params[:id]
redirect_to_index
end
unfortunately i found that remove_item isn''t my CardItem class but a
String. how could this happen? and how could i get cart_item in my
remove_from_cart method by rewritng my code?
--
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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mon, May 2, 2011 at 7:03 AM, SonicMisora <sonicmisora-KN7UnAbNpbg@public.gmane.org> wrote:> def remove_from_cart > @cart = find_cart > remove_item = params[:id] > redirect_to_index > end > unfortunately i found that remove_item isn''t my CardItem class but a > String.Of course it''s a String - that''s what "query*string*" parameters are :-) - remove_item = params[:id] + remove_item = CardItem.find(params[:id]) HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.