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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Try map.resources :room instead. This will use restful routing which will do exactly what you want it to do, but instead list is called "index". On Jan 9, 2008 4:40 PM, Chubbs <acetinick-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 > > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
mmm but how do i create the route for /room/technology? On Jan 9, 5:12 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try map.resources :room instead. > > This will use restful routing which will do exactly what you want it to do, > but instead list is called "index". > > On Jan 9, 2008 4:40 PM, Chubbs <acetin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > 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 > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On Jan 9, 2008 4:46 PM, Chubbs <acetinick-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > mmm but how do i create the route for /room/technology? > > > On Jan 9, 5:12 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Try map.resources :room instead. > > > > This will use restful routing which will do exactly what you want it to > do, > > but instead list is called "index". > > > > On Jan 9, 2008 4:40 PM, Chubbs <acetin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > > > 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 > > > > -- > > Ryan Bigghttp://www.frozenplague.net > > Feel free to add me to MSN and/or GTalk as this email. > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 ? On Jan 9, 5:20 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. > > On Jan 9, 2008 4:46 PM, Chubbs <acetin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > mmm but how do i create the route for /room/technology? > > > On Jan 9, 5:12 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Try map.resources :room instead. > > > > This will use restful routing which will do exactly what you want it to > > do, > > > but instead list is called "index". > > > > On Jan 9, 2008 4:40 PM, Chubbs <acetin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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 > > > > -- > > > Ryan Bigghttp://www.frozenplague.net > > > Feel free to add me to MSN and/or GTalk as this email. > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On Jan 9, 2008 4:59 PM, Chubbs <acetinick-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 ? > > On Jan 9, 5:20 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > 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. > > > > On Jan 9, 2008 4:46 PM, Chubbs <acetin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > > > mmm but how do i create the route for /room/technology? > > > > > On Jan 9, 5:12 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Try map.resources :room instead. > > > > > > This will use restful routing which will do exactly what you want it > to > > > do, > > > > but instead list is called "index". > > > > > > On Jan 9, 2008 4:40 PM, Chubbs <acetin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > 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 > > > > > > -- > > > > Ryan Bigghttp://www.frozenplague.net > > > > Feel free to add me to MSN and/or GTalk as this email. > > > > -- > > Ryan Bigghttp://www.frozenplague.net > > Feel free to add me to MSN and/or GTalk as this email. > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Jan 9, 5:31 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. > > On Jan 9, 2008 4:59 PM, Chubbs <acetin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > 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 ? > > > On Jan 9, 5:20 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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. > > > > On Jan 9, 2008 4:46 PM, Chubbs <acetin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > mmm but how do i create the route for /room/technology? > > > > > On Jan 9, 5:12 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Try map.resources :room instead. > > > > > > This will use restful routing which will do exactly what you want it > > to > > > > do, > > > > > but instead list is called "index". > > > > > > On Jan 9, 2008 4:40 PM, Chubbs <acetin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > 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 > > > > > > -- > > > > > Ryan Bigghttp://www.frozenplague.net > > > > > Feel free to add me to MSN and/or GTalk as this email. > > > > -- > > > Ryan Bigghttp://www.frozenplague.net > > > Feel free to add me to MSN and/or GTalk as this email. > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jan 9, 2008, at 7:29 AM, Chubbs wrote:> 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 ?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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---