Hi,
Could somewhat offer guidance on this situation.
Say I have a Product model and an associated resource reference
defined:
map.resources :products, :collection => { :search => :get }
I need to access the search action but have a different view
(generally RJS) rendered depending on the context of the call.
For example, if called from an order assembly page I might need the
resulting product collection displayed with add to basket links.
Whereas on another page I might need them rendered with add to
purchase order links.
I see to obvious solutions:
1. Define multiple actions within a single resource. They would
essentially have the same code but would call different RJS view code
to render the result.
map.resources :products, :collection => { :sales_order_search
=> :get, :purchase_order_search => :get }
2. Have multiple resources such as as:
map.resources :sales_order_products, :collection => { :search
=> :get }
map.resources :purchase_order_products, :collection =>
{ :search => :get }
If going down route 2 I'd probably just repurpose the index action to
check for a search_string param to narrow the results returned.
Both seem less than perfect, although I'm tended towards solution 1.
Although I've only highlighted two view contexts there could be more,
I would suggest 3 or 4 could be common. How would you handle this
situation?
Thanks, Andrew
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---