Hey all, love the RoRTalk group This might just be a general Ruby question, but I ran into the problem in Rails so I''ll put it out here. I''m trying to re-use some routing code. this_and_that = proc { |a_resource| a_resource.resources :this do |this| this.resources :that end } map.resources :foos do |foos| foos.resources :bazs this_and_that foos.resources :bats this_and_that end I''m pretty sure I need to fix these lines: foos.resources :bazs this_and_that All the best, Collin T Miller --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Collin Miller wrote:> I''m trying to re-use some routing code. > > this_and_that = proc { |a_resource| > a_resource.resources :this do |this| > this.resources :that > end > } > > map.resources :foos do |foos| > foos.resources :bazs this_and_that > foos.resources :bats this_and_that > endIt''s not at all clear what you expect this to do. This isn''t even valid Ruby syntax! Can you explain the result you''re trying to achieve? Pete Yandell http://notahat.com/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I think what he wants is this: this_and_that = proc { |a_resource| a_resource.resources :this do |this| this.resources :that end } map.resources :foos do |foos| foos.resources :bazs &this_and_that foos.resources :bats &this_and_that end Note the & before this_and_that. Trevor On 19-Jul-07, at 9:31 PM, Pete Yandell wrote:> > Collin Miller wrote: >> I''m trying to re-use some routing code. >> >> this_and_that = proc { |a_resource| >> a_resource.resources :this do |this| >> this.resources :that >> end >> } >> >> map.resources :foos do |foos| >> foos.resources :bazs this_and_that >> foos.resources :bats this_and_that >> end > > It''s not at all clear what you expect this to do. This isn''t even > valid > Ruby syntax! > > Can you explain the result you''re trying to achieve? > > Pete Yandell > http://notahat.com/ > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---