Partials between controllers. . .and one-to-many in practice

Hi all,


I have a setup with two entities: Orders and Events. Currently, they're one-to-one (per the client's request), but I've placed them in separate tables not only because Events have a lot of info, but I foresee it becoming one-to-many. Because I'm using the AjaxScaffold plugin (and don't wanna give it up, unless, of course, you've got a better idea) I need to render a partial from another controller (EventsController) in the 'edit' of (OrdersController). Is there any simple way to 1) link the other partial in and 2) have the functionality from the EventsController do its part before the OrdersController ?

My guess would be to have a lot of code like so in the OrdersController (plural because that's the way ajax_scaffold does it):

  def create
    @order =[:order])
    @event =[:event])

    $order.event = @event

. . .but I'm not absolutely sure, and I'd rather know before I go breaking the existing, working, code to refactor the views to support this.

render :partial => ‘/event/edit’

When the path starts with “/”, Rails will start at app/views, allowing you to access whatever controller’s views you want.

As for running code in the EventsController, that is not possible outside of straight redirecting to that action. Sounds like you are getting some duplicate code that should be pulled into it’s own class and placed in lib/class_name.rb.


I see. . .thanks!