1

I have a Presentation Model which I create in the usual way through a form.

The Presentation Model has two nested resources: a Recording Model and a SlideDeck Model:

class Presentation < ActiveRecord::Base

has_one :recording
has_one :slide_deck

end

I have a Flash component that allows a user to record a Presentation and add slides through its duration. Once a user has finished creating and editing the Presentation they click save.

At this point I need to create the Recording and the SlideDeck as nested resources on the Presentation. This means creating two Models from a single form.

My question is where should this page sit? If the component was creating just the Recording, the page would be rendered from a new action on the recording_controller and if it was creating just the SlideDeck, the page would be rendered from a new slide_deck_controller. However in this case I am creating both at the same time.

So where should the component live? Should it be rendered by an action on the presentation_controller; another edit action? In one sense this page allows editing of the Presentation through creating its nested resources.

Undistraction
  • 42,754
  • 56
  • 195
  • 331
  • Sounds like this would go into PresentationsController#new and #create. – Rob Davis May 16 '12 at 20:11
  • @RobDavis Thanks. That would make sense, apart from 2 problems. 1. I want to be able to create the Presentation independently of making the Recording and 2. From a usability perspective, I want some sort of segregation between the task of creating/editing a presentation - Its name, description etc and the task of recording/editing the Recording and SlideDeck. Given that I require these two tasks inhabit separate pages, is there anything wrong with treating the Recording/Editing task as a separate action on the PresentationsController? – Undistraction May 16 '12 at 20:16

2 Answers2

1

Normally, PresentationController#edit (and the corresponding #update) is used to modify the 'Presentation' model. If you already have #edit and the corresponding #update and you want the recording to be created in a separate action, then you need to create another pair of actions. Another option is you can make #update generic enough to handle "normal edit" and 'creation of recording'. In that case both #edit and #record actions can submit the form to #update action.

Salil
  • 9,534
  • 9
  • 42
  • 56
0

I would think it should be a part of nested_attributes in Presentation model, than you can add all of that info to presentation with either create or update action

Yuriy Goldshtrakh
  • 2,014
  • 1
  • 11
  • 7
  • Thanks. I agree. This is most probably the best way to commit the data once the Recording is saved, but where should the player live? What action should render its page? – Undistraction May 16 '12 at 20:22