Difference between _path and :action => 'some_method'

Hello. So solved some error with just replacing path method with calling
But I’m curious why in absolutely same in first case _path worked
in second it causer an error which is solved just by changing syntax
not the sence of what is happening)
First case:

<%= form_for @answer, {:url => create_answer_test_path(@test), :html =>
{:id=>“form_#{@key.position}”}, :remote=>true}

worked with no problem

<%= button_to ‘-’, {:url=>delete_answer_test_path(@test)},
:method=>:delete, :remote =>true %>

Caused several types of errors:

ActionController::RoutingError (No route matches
:controller=>“tests”, :id=>nil})

Started DELETE
for at 2013-03-18 12:08:36 +0400 (??? for some reason started
previous method and ‘delete_answer’ was just in server call)

But when I replaced it with {:controller=>‘tests’, :action =>
‘delete_answer’} (which is basically just another way of syntax, but not
what is going on) works fine.


On Monday, March 18, 2013 8:33:15 AM UTC, Barry wrote:

You haven’t said what the route is, but it would appear that you’ve made
a member route of a collection: this is an action that does something
a specific instance of your Test class. What this error is saying is
that @test is apparently unsaved so doesn’t have an id, which doesn’t
any sense to rails (although of course it doesn’t know if you then use
id parameter or not)