Another try with REST

I’m using edge rails.

My routes.rb is:

map.connect ‘:controller/service.wsdl’, :action => ‘wsdl’

Install the default route as the lowest priority.

map.connect ‘:controller/:action/:id’

map.resources :team <---- THIS LINE ADDED BY ME

Also have a team_controller.rb, a team.rb model and scaffolding for it.

If I invoke /team/1;edit url it shows me the edit form for team 1,
that’s right. But if I invoke /team/1 I receive the response:

Unknown action
No action responded to 1

Why it didn’t show me the team 1?

Eduardo Yáñez Parareda wrote:

I’m using edge rails.

My routes.rb is:

map.connect ‘:controller/service.wsdl’, :action => ‘wsdl’

Install the default route as the lowest priority.

map.connect ‘:controller/:action/:id’

map.resources :team <---- THIS LINE ADDED BY ME

Also have a team_controller.rb, a team.rb model and scaffolding for it.

If I invoke /team/1;edit url it shows me the edit form for team 1,
that’s right. But if I invoke /team/1 I receive the response:

Unknown action
No action responded to 1

Why it didn’t show me the team 1?

In routes.rb “map.connect ‘:controller/:action/:id’” is the catch all of
your routes.

When a request comes in, rails tries to find a in your routes file by
going route by routes form the top to the bottom. So as soon as it
finds a match, it stops looking. So “/team/1” matches
“:controller/:action/:id” as controller “team” and action “1”.

So if you put the map.resources line above your other stuff it will work
as intended and match against the resource routes rather than the
default route.

This is also why this comment is there:

Install the default route as the lowest priority.

It’s telling you too keep that route at the bottom so it doesn;t
interfere with any other routes.

thats because rails priorizes routes. the first matching route is taken,
so
in your routes, its the standard route, and controller team, action 1 is
called.
move the resources up before all other routes and everything should work

2006/8/14, Eduardo Yáñez Parareda [email protected]:

map.resources :team <---- THIS LINE ADDED BY ME


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Michael S. [email protected]

www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs