Route z contraints

Mam tak zdefiniowany routing:

[code]namespace :trac do
constraints IpRestrictor do
post ‘ip’ => ‘has#ip’, :as => :ip
end
end

class IpRestrictor
def self.matches?(request)
request.remote_ip =~ /93.219.182.147/
end
end[/code]
Kiedy wywoluje ten link uzywajac curla dostaje blad:

[code]curl -d “id=6236&transaction=3424234234234234234234” “http://localhost:3000/trac/has/ip

Started POST “/trac/has/ip” for 127.0.0.1 at 2011-11-23 18:54:26 +0100

ActionController::RoutingError (No route matches “/trac/has/ip”):[/code]
kiedy zmienie na metode GET wszystko jest ok. Dlaczego dla POST nie dziala?

Wiecej informacji z curla:

[code]* About to connect() to localhost port 3000 (#0)

  • Trying ::1… Connection refused
  • Trying 127.0.0.1… connected
  • Connected to localhost (127.0.0.1) port 3000 (#0)

POST /trac/has/ip HTTP/1.1
User-Agent: curl/7.21.0 (i686-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
Host: localhost:3000
Accept: /
Content-Length: 56
Content-Type: application/x-www-form-urlencoded

< HTTP/1.1 404 Not Found
< Content-Type: text/html
< Content-Length: 646
< X-Runtime: 0.007196
< Server: WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18)
< Date: Wed, 23 Nov 2011 18:17:15 GMT
< Connection: Keep-Alive
<[/code]

Nie rozumiem dlaczego zwraca mi blad ActionController::RoutingError (No route matches) nawet kiedy nie uzywam klasy IPRestrictor:

ActionController::RoutingError (No route matches)

rake routes zwraca mi:

trac_ip POST /trac/ips(.:format)           {:action=>"ip", :controller=>"trac/has"}

namespace :trac do constraints IpRestrictor do post 'ip' => 'has#ip', :as => :ip end end

Started POST "/trac/has/ip" for 127.0.0.1 at 2011-11-23 18:54:26 +0100
 trac_ip POST /trac/ips(.:format)

Ścieżka to /trac/ips, a nie /trac/has/ip :wink:

Dzieki Sebcioz,

juz myslalem ze to blad w Railsach :smiley:

Przy okazji w jakim katalogu moge stworzyc plik z ta sama klasa tylko dla IP 127.0.0.1 lokalnego aby moc uzyc jej do testow funkcjonalnych? W katalogu test/mocks/test?