I am trying to implement a restful app, but I have found some problems with the design, when I have thought in implementig STI. I will try to explain. Only as a example, you may suppose this models ======================Class Person < ActiveRecord::Base has_many :widgets end Class Customer < Person end Class Employee < Person end Class Widget < ActiveRecord::Base belongs_to :person end ====================Then I would like to define these resources in config/routes.rb map.resources :customers do |customer| customer.resources :widgets end map.resources :employees do |employee| employee.resources :widgets end Is this the correct way to abord this problem? Can I go in the REST style way for this case? I will appreciate any comment of someone with some experience with these questios. Thanks Juan M. Cervera -- 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 -~----------~----~----~----~------~----~------~--~---
Juanma Cervera
2007-Jan-04 10:28 UTC
Re: Mixing Single Table Inheritance and RESTful routes.
I have tried to find a solution, with no luck. There is no problem in defining the routes in routes.rb, but it seems that this will not work because I have only one set of named routes for the widgets resources. Does anybody see a better way or an alternative for this problem? It is important for me because in my real problem I have several classes that I can implement with STI, they are different resources in my app and each one needs its resftul controller. But they all have the same nested resource and I want only one restful controller, for all the cases. I pretend to be DRY in the design. Anybody thinks there is a way to implement this? Please give me some advise. Thanks in advance. Juan M. cervera -- 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 -~----------~----~----~----~------~----~------~--~---
Juanma Cervera
2007-Jan-08 05:24 UTC
Re: Mixing Single Table Inheritance and RESTful routes.
I think I have tried very hard and still no luck.
I can have the restful routes working without problems
map.resources :customers do |customer|
customer.resources :widgets,
:name_prefix => ''customer_''
end
map.resources :employees do |employee|
employee.resources :widgets
:name_prefix => ''employee_''
end
Now I have named routes like customer_new_widget_path or
employee_widgets_path but I found difficult to be in the DRY way, with
only on controller for widgets, mostly for the associated views.
Is possible that nobody has ever tried something like this?
Or I can''t explain the question in a correct way, and nobody
understands
me.
Well, I think I''m going to abandon this idea.
Thanks
Juan M. Cervera
--
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
-~----------~----~----~----~------~----~------~--~---