Furthermore, in order to refer to the parent (in this case, 'Video'), I
need to set video_id:integer for Script. Am I correct ?
how can I actually associate a new 'script' entry with
its parent, 'video', in making a new 'Script' entry ?
For example, in 'index.html.erb' for NewScript page, I tried to put
<td><%= script.video_id %></td>
I don't understand. index.html.erb is for showing the list of
something. What's "NewScript" got to do with it?
You may be on *almost* the right track though. Assuming you get to
views/scripts/new.html.erb by clicking on something associated with a
video, you can set the new script object's video_id in the controller,
and add a hidden field to hold it (for submission to create).
@script.video = Video.where(:video_id)
That where-clause isn't going to work. It's just saying "where
there's a valid video_id". Maybe you mean where :video_id => video.id
(if there is a variable called video), or maybe video_id.
Anyway, more direct would be simply "@script.video_id = video_id". No
searching needed. Assuming of course that you already have the
BTW, do you know the definition of "Where Clause"? It's a fat guy who
dresses up in a red suit and gives out presents, when the moon is