Hey Everyone, I''m wondering if the statement below are redundant? Once you define the resources for a particular controller, that should be it right? I''m assuming all I need is the second statement below. map.resources :customers map.resources :customers, :has_many => :accounts Thanks! Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yes all you need is the second statement. If you have both try running the command rake routes from the rails root directory it will show you what the two would do.(Or the one if you remove the top one.) THe second line could also be written like map.resources :customers do |customer| customer.resources :accounts end You would need that if you wanted to add a member or collections route to accounts On Apr 6, 1:10 pm, internetchris <ch...-031BekU2q/6zp2J5h9KejqJePFAbegks@public.gmane.org> wrote:> Hey Everyone, > > I''m wondering if the statement below are redundant? Once you define > the resources for a particular controller, that should be it right? > I''m assuming all I need is the second statement below. > > map.resources :customers > map.resources :customers, :has_many => :accounts > > Thanks! > > Chris--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Freddy,
So I''m not sure if my routes file is setup correctly after your last
comment. Would you mind taking a look at it?
ActionController::Routing::Routes.draw do |map|
map.resources :customers, :has_Many => :accounts
map.resources :customers, :member => {:info_for_account_form
=> :post}
map.resources :owners, :has_many => :accounts
map.resources :owners, :member => {:info_for_account_form => :post}
map.resources :usertypes, :has_many => :accounts
map.resources :accounts, :belongs_to => :owner
map.resources :accounts, :belongs_to => :customer
map.resources :accounts, :collection =>
{:auto_complete_belongs_to_for_account_customer_name => :post}
map.resources :accounts, :collection =>
{:auto_complete_belongs_to_for_account_owner_name => :post}
# Install the default routes as the lowest priority.
map.connect '':controller/:action/:id''
map.connect '':controller/:action/:id.:format''
end
On Apr 6, 2:29 pm, Freddy Andersen
<fre...-RCI/mp9mI1I6GGFevw1D/A@public.gmane.org>
wrote:> Yes all you need is the second statement. If you have both try running
> the command rake routes from the rails root directory it will show you
> what the two would do.(Or the one if you remove the top one.) THe
> second line could also be written like
>
> map.resources :customers do |customer|
> customer.resources :accounts
> end
>
> You would need that if you wanted to add a member or collections route
> to accounts
>
> On Apr 6, 1:10 pm, internetchris
<ch...-031BekU2q/6zp2J5h9KejqJePFAbegks@public.gmane.org>
> wrote:
>
>
>
> > Hey Everyone,
>
> > I''m wondering if the statement below are redundant? Once you
define
> > the resources for a particular controller, that should be it right?
> > I''m assuming all I need is the second statement below.
>
> > map.resources :customers
> > map.resources :customers, :has_many => :accounts
>
> > Thanks!
>
> > Chris
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Should look more like this:
map.resources :customers,
:member => { :info_for_account_form => :post },
:has_Many => :accounts
map.resources :owners,
:member => { :info_for_account_form => :post },
:has_many => :accounts
map.resources :usertypes,
:has_many => :accounts
map.resources :accounts,
:belongs_to => [ :owner, :customer ],
:collection =>
{ :auto_complete_belongs_to_for_account_customer_name => :post,
:auto_complete_belongs_to_for_account_owner_name
=> :post }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---