Hey, i have- map.resources :courses, :has_many => :pages now what if i wanted for courses to has_many => :forums as well? can i just do map.resources :courses, :has_many => :pages, :forums ?? because that doesn''t work. whats the syntax for- has many blank AND blank.. lol reall noobie i know, but i just don''t know how to do it. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > i have- map.resources :courses, :has_many => :pages > > now what if i wanted for courses to has_many => :forums as well? > > can i just do map.resources :courses, :has_many => :pages, :forums >Nope, it would be: map.resources :courses, :has_many => [:pages, :forums] You map it to an array. In Ruby any hash style assignments in a method call, which this is, but must come at the end to be implicitly converted to a hash. In the initial example you are doing this: map.resources(:courses, {:has_many => :pages}) And that works just as well as the normal version, but it''s not as readable. If you did it your way, Ruby wouldn''t be able to make the last arguments a hash as you have just a key as the last argument (your :forums looks like an additional argument to map.resources not a part of :has_many). Anyway, answered in the first line of code, hopefully the rest may make it slightly clearer. Cheers, Andy -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Have you tried? map.resources :courses, :has_many => [:pages, :forums] On 8 Abr, 02:31, David Zhu <dzwestwindso...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey, > > i have- map.resources :courses, :has_many => :pages > > now what if i wanted for courses to has_many => :forums as well? > > can i just do map.resources :courses, :has_many => :pages, :forums > > ?? because that doesn''t work. whats the syntax for- has many blank AND > blank.. > > lol reall noobie i know, but i just don''t know how to do it.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
oh the brackets. thanks guys. :) On Apr 8, 4:04 am, ultrayoshi <david.morci...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Have you tried? > > map.resources :courses, :has_many => [:pages, :forums] > > On 8 Abr, 02:31, David Zhu <dzwestwindso...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hey, > > > i have- map.resources :courses, :has_many => :pages > > > now what if i wanted for courses to has_many => :forums as well? > > > can i just do map.resources :courses, :has_many => :pages, :forums > > > ?? because that doesn''t work. whats the syntax for- has many blank AND > > blank.. > > > lol reall noobie i know, but i just don''t know how to do it.- Hide quoted text - > > - Show quoted text --- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
when I have more than one nested ''has_many'' resource, i think about creating a namespace... http://seanbehan.com/ruby-on-rails/nesting-resources-in-rails-routes-rb-with-namespaces/ ...this keeps your other controllers (forums, pages) clean and restful On Apr 7, 8:31 pm, David Zhu <dzwestwindso...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey, > > i have- map.resources :courses, :has_many => :pages > > now what if i wanted for courses to has_many => :forums as well? > > can i just do map.resources :courses, :has_many => :pages, :forums > > ?? because that doesn''t work. whats the syntax for- has many blank AND > blank.. > > lol reall noobie i know, but i just don''t know how to do it.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
oh yeah then what if i wanted-- a has many b, and b has many c, and c has many d how would i do that in a route? like multiple stacked layers, how would i write that in my routes.rb? On Apr 8, 11:18 am, bseanvt <bsea...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> when I have more than one nested ''has_many'' resource, i think about > creating a namespace...http://seanbehan.com/ruby-on-rails/nesting-resources-in-rails-routes-... > ...this keeps your other controllers (forums, pages) clean and restful > > On Apr 7, 8:31 pm,DavidZhu<dzwestwindso...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hey, > > > i have- map.resources :courses, :has_many => :pages > > > now what if i wanted for courses to has_many => :forums as well? > > > can i just do map.resources :courses, :has_many => :pages, :forums > > > ?? because that doesn''t work. whats the syntax for- has many blank AND > > blank.. > > > lol reall noobie i know, but i just don''t know how to do it.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.