Routes path problem when using link_to_remote


#1

Hello there,

My routes.rb has following

map.resources “parties” , :controller=> “political_parties” ,
:collection => {:states => :get , :nationals => :get }

In one of my views i was trying to do something like this

<%= link_to_remote “State Parties” , :url=> states_parties_path ,:update
=> {:success => ‘parties_list’} %>

But I was getting following error on log

ActionController::MethodNotAllowed (Only get, put, and delete requests
are allowed.):

Any idea whay this is?


#2

On 21 Mar., 08:40, Shardul M. removed_email_address@domain.invalid
wrote:

=> {:success => ‘parties_list’} %>

But I was getting following error on log

ActionController::MethodNotAllowed (Only get, put, and delete requests
are allowed.):

Any idea whay this is?

In your routes file you defined that you only wanted GET requests two
the states action. Currently it doesn’t work since Prototype makes
POST requests by default. You have two opportunities:

A) Correct your routes file:
map.resources “parties” , :controller=>
“political_parties” , :collection => {:states => :post , :nationals
=> :get }

B) Correct the link:
<%= link_to_remote “State Parties” , :url=>
states_parties_path, :update => {:success => ‘parties_list’}, :method
=> :get %>

The ActionController::MethodNotAllowed error in general means that you
have attempted to call an action that is not allowed to be called with
that method. E.g. you can’t POST to the show action, it only allows
GET.


Cheers,
David K.
http://twitter.com/rubyguy