This might actually work :-)
<%= link_to 'delete', admin_products_path(product),
:method => :delete, :confirm => 'Are you sure?' %>
Rick
On Nov 23, 12:40 pm, Rick <[EMAIL PROTECTED]> wrote:
> Hello Alberto,
>
> In your view, what are you trying to say with [:admin, product].
> Is it perhaps {:controller => "admin/product"}?
>
> rake routes on your routes.rb shows:
>
> DELETE /admin/products/:id
> {:action=>"destroy", :controller=>"admin/products"}
>
> So you should be able to use:
>
> <%= link_to 'delete', products_path(product), :method => :delete,
> :confirm => 'Are you sure?' %>
>
> Rick
>
> On Nov 23, 8:24 am, cardinallijr <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > I'm trying to implement an admin control panel for my application and
> > everything seems to work fine, except when I try to call the destroy
> > method from the view. I really tried to search for a solution, reading
> > some routing rails articles, but can't figure out what's going on.
> > When I call the method from the console it works. Calling it from the
> > view redirects to the list action, but the product is not deleted.
>
> > View:
> > -------
> > <% for product in @products %>
> > <%= link_to 'delete', [:admin, product],:confirm => 'Are you
> > sure?',:method => :delete %>
> > <% end %>
>
> > My routes.rb:
> > -------------------
> > map.namespace :admin do |admin|
> > admin.resources :categories
> > admin.resources :subcategories
> > admin.resources :products
> > end
>
> > Controller:
> > --------------
> > def destroy
> > @product = Product.find(params[:id])
> > @product.destroy
> > respond_to do |format|
> > format.html { redirect_to(products_url) }
> > end
> > end
>
> > Thanks for your help,
>
> > --
> > Alberto
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---