A while ago I listened to an interview with DHH where he outlined the 
advantages of using new controllers rather than creating custom actions in 
existing controllers.

I have been trying this approach, and like the way it improves organisation 
and simplifies routes and also encourages scoping/namespacing to group 
resources.

The one thing I have found not too neat is the handling of errors between 
resources.  In particular, if I need to use partials from the original 
resouce (eg to resend the show action), the pathname for the partials are 
wrong since they try to prefix with the alternative controller name.  This 
can be overcome by using absolute paths for partial names.  But this tends 
towards cluttered and brittle code.

Mostly I get over this by using ajax which allows me to render nothng 
inline and just re-display the partial that displays error messages.   
However, I have a products template that includes a form for uploading 
images.  I was doing a rewrite in this area and tried moving the 
create_image method out of products controller and into an images 
controller/resource.

But since the multipart form cannot be remoted, I am stuck with an html 
request.  To display an error message from this action now forces me to 
either redirect (which will reset the page to its initial show state) or 
use absolute pathnames for the partials in the products#show so I can call 
products#show from images#create.  (there are quite a few partials involved)

It occurred to me that this may have been addressed, or that there may be a 
workaround to override the default partial pathname.  

I have tried googling and not come up with very much that helps - I cant 
really think of a succinct phrase to google.

Does anyone have any ideas or suggestions (or am I missing something).

Tonypm


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/1fa26762-956f-4971-af12-ef9ad9d3ee5c%40googlegroups.com.

Reply via email to