I have a link:
<%= link_to_remote "Edit", {:url => edit_book_url(book)}, {:href =>
edit_book_url(book)} %>
It produce a tag: <a href="http://localhost:3000/books/1;edit"
onclick="new Ajax.Request('http://localhost:3000/books/1;edit’,
{asynchronous:true, evalScripts:true}); return false;">Edit</a>
My ./config/routes.rb file is:
ActionController::Routing::Routes.draw do |map|
map.resources :books, :members => {:delete => :get}
map.connect ':controller/service.wsdl', :action => 'wsdl'
map.connect ':controller/:action/:id.:format'
map.connect ':controller/:action/:id'
end
In log I get:
ActionController::RoutingError (no route found to match "/books/1;edit"
with {:method=>:post})
What's wrong? Should I add map.connect ':controller/:id;:action'?
PS.
I would not like to just solve the problem. I'd like to solve it in
correct way.
Hey,
how about:
link_to_remote "Edit", {:url => edit_book_url(book), :method => :get},
{:href => edit_book_url(book)}
HTH,
Trevor
A bit off-topic, but.....
map.resources :books, :members => {:delete => :get}
What is this? It seems wrong. The CRUD method is destroy. Are you
trying to "alias" destroy with delete? Does your custom delete method
do something different than destroy? In any case the syntax looks
wrong to me.
It should look more like:
map.resources :books, :member => { :delete => :delete }
Notice ":member" is singular and you should NOT be doing ":get" if you
are deleting, or modifying, the resource in any way.
A bit off-topic, but.....
map.resources :books, :members => {:delete => :get}
What is this? It seems wrong. The CRUD method is destroy. Are you
trying to "alias" destroy with delete? Does your custom delete method
do something different than destroy? In any case the syntax looks wrong
to me.
It should look more like:
map.resources :books, :member => { :delete => :delete }
Notice ":member" is singular and you should NOT be doing ":get" if you
are deleting, or modifying, the resource in any way.
It a hack for browser which do not have JavaScript. It will contains only
button "Do you really want to delete?" which send it (unfortunatly) by
POST.
User click on "Delete" --> Does he have JS support? ---Yes---> Send delete
> request and
No gets destroy.rjs
>
\> He is redirect to confirmation
page delete.rhtml which send
request by POST.
Regards