Hi, I have one controller in the /app/controllers/animals_controller.rb directory, and another in /app/controllers/production/services_controller.rb. The thing is that one Animal has many Services, and i''d like to access to them using something like: http://localhost:3000/animals/1/production/services/1 or at least with: http://localhost:3000/animals/1/services/1 I tried the last one adding in routes.rb: map.resources :animals, :has_many => :services but it throws me an error: uninitialized constant ServicesController any idea? Thanks. -- Posted via http://www.ruby-forum.com/.
On Mon, Oct 19, 2009 at 11:16 AM, Sergio Aristizabal < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > > I have one controller in the /app/controllers/animals_controller.rb > directory, and another in > /app/controllers/production/services_controller.rb. The thing is that > one Animal has many Services, and i''d like to access to them using > something like: > > http://localhost:3000/animals/1/production/services/1 > > or at least with: > > http://localhost:3000/animals/1/services/1 > > I tried the last one adding in routes.rb: > > map.resources :animals, :has_many => :services > > but it throws me an error: uninitialized constant ServicesController > > any idea? > > Thanks. >Your ServicesController is in a non-standard location. Thus, what''s the reasoning for having ServicesController within the production directory? In any case, you should be able to do the following: config.load_paths += %W( #{RAILS_ROOT}/app/controllers/production ) The above adds the production directory to your load path. Good luck, -Conrad> -- > Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
On Mon, Oct 19, 2009 at 11:27 AM, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mon, Oct 19, 2009 at 11:16 AM, Sergio Aristizabal < > rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> >> Hi, >> >> I have one controller in the /app/controllers/animals_controller.rb >> directory, and another in >> /app/controllers/production/services_controller.rb. The thing is that >> one Animal has many Services, and i''d like to access to them using >> something like: >> >> http://localhost:3000/animals/1/production/services/1 >> >> or at least with: >> >> http://localhost:3000/animals/1/services/1 >> >> I tried the last one adding in routes.rb: >> >> map.resources :animals, :has_many => :services >> >> but it throws me an error: uninitialized constant ServicesController >> >> any idea? >> >> Thanks. >> > > Your ServicesController is in a non-standard location. Thus, what''s the > reasoning for having ServicesController within the production directory? > In any case, you should be able to do the following: > > config.load_paths += %W( #{RAILS_ROOT}/app/controllers/production ) >BTW, the above line goes into your environment.rb file within the Rails::Initializer block. -Conrad> > The above adds the production directory to your load path. > > Good luck, > > -Conrad > > >> -- >> Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
''production/services'' should work as the controller name. The "non-standard location" should not be an issue. In my app i dont need that init line. 2009/10/19, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> On Mon, Oct 19, 2009 at 11:27 AM, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On Mon, Oct 19, 2009 at 11:16 AM, Sergio Aristizabal < >> rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >>> >>> Hi, >>> >>> I have one controller in the /app/controllers/animals_controller.rb >>> directory, and another in >>> /app/controllers/production/services_controller.rb. The thing is that >>> one Animal has many Services, and i''d like to access to them using >>> something like: >>> >>> http://localhost:3000/animals/1/production/services/1 >>> >>> or at least with: >>> >>> http://localhost:3000/animals/1/services/1 >>> >>> I tried the last one adding in routes.rb: >>> >>> map.resources :animals, :has_many => :services >>> >>> but it throws me an error: uninitialized constant ServicesController >>> >>> any idea? >>> >>> Thanks. >>> >> >> Your ServicesController is in a non-standard location. Thus, what''s the >> reasoning for having ServicesController within the production directory? >> In any case, you should be able to do the following: >> >> config.load_paths += %W( #{RAILS_ROOT}/app/controllers/production ) >> > > BTW, the above line goes into your environment.rb file within the > Rails::Initializer > block. > > -Conrad > > >> >> The above adds the production directory to your load path. >> >> Good luck, >> >> -Conrad >> >> >>> -- >>> Posted via http://www.ruby-forum.com/. >>> >>> >> >>> >> > > > >-- Von meinen Mobilgerät aus gesendet