problems with defining routes

hey i am having problems when defining routes like this.

  map.room 'room/:name', :controller => 'room', :action => 'show'

when i try goto any url such as:
/room/123
/room/technology

it works fine to goto the show method with a param :name.

but when i want to use my other actions such as 'list' it still treats
it as room/:name and will direct it to my show action.

eg.
room/list gives

**NoMethodError in Room#show

Showing room/show.rhtml where line #1 raised:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.name

mmm but how do i create the route for /room/technology?

Ahh, the wonders of restful routing elude you:

map.resources :room, :member => { :technology => :get }

Or if you’re doing it for a whole bunch of rooms:

map.resources :room, :collection => { :technology => :get }

Whether you do :member or :collection determines whether you do technology_room_path(@room) or technology_rooms_path(@room).

I covered restful routing a few days ago on this list and wrote a smallish tutorial for it: http://frozenplague.net/?p=108

If you have any questions do not hesitate to contact me through the list or through GTalk or MSN at this email.

im a bit confused

im just wanting to call the show action for a name for the room.

eg,
/room/technology
should goto /room/show with param[:name] = technology,
so i can show the subtopics within technology

would i have to create a maps.resources for each of my room names ?

No, map.resources :rooms will automatically define the routes you need for CRUD’ding resources: index, show, new, create, edit, update & delete.

This means when you do /rooms/technology it’ll actually pass in “technology” as params[:id], not params[:name]. Just a minor alteration in your code should fix this.

ahh i get you,i change it and got it working

ok ill start using RESTful routing from now on,

thanks for the advice

-chubbs

Just another detail: you can still have the room name in the URL with a custom Room#to_param that returns the name, or the trick "#{id}-name" you can see out there. That parameter goes to params[:id] anyway.

-- fxn