Forum: Ruby on Rails routes path problem when using link_to_remote

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Shardul M. (Guest)
on 2009-03-21 09:40
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?
(Guest)
on 2009-03-21 10:36
(Received via mailing list)
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
This topic is locked and can not be replied to.