I need to run a couple more statements than just the create. It’s
creating associated objects, but I don’t think it should be done as
part of a create hook. There’s only like three lines that need to be
duplicated. So I guess I’ll move it into a module.
I think I might be missing something though. So let me give a bit more
class Video < AR
class Asset < AR; end
The create is going to be a simple
@video = Video.create params[:video]
From here I need to create a couple assets. I could just do this in
a create hook, except for the fact that I need to pass them a frame
number. This never gets stored anywhere but gets sent back to a
So I feel weird about putting a frame_number accessor on either Video
or Asset. They’d only ever use it once, and it just seems like it
shouldn’t go there.
Doing this all in a create hook would also make testing tougher
because I’d have to stub lots of stuff.
I think what I should do is write a new builder/method or class that
handles all of this. I can call that method, passing it all the info
I need, and it will create the video, the assets, and tell the other
server about it. That way I can encapsulate the entire building
process by one method, so I don’t have any duplication, and my AR
classes stay lightweight and don’t have to worry about constructing
all these other things.
Sorry if that’s a bit rambly, it’s basically me talking things
through. Thanks for listening