>
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.