-
-
Save ryana/1034924 to your computer and use it in GitHub Desktop.
class Vid < AR::Base | |
after_save :encode | |
private | |
def encode | |
VidEncoder.go(self) | |
end | |
end | |
class VidEncoder | |
include Rails.application.routes.url_helpers | |
# default_url_options should be set by server setup or | |
# a setup block in your test system | |
class < self | |
def go(obj) | |
Zencoder.stuff(:source_url => url_for(obj)) | |
end | |
end | |
end |
The activerecord extension is wrong. default_url_options is defined on ZencodeCommunicator. you gotta set the host parameter just like the error says. you do this in your test system, config/initializers, or in a before_filter in application_controller.
sorry I can't spend more time teaching you this stuff. gotta do my own work :)
Last last comment: I didn't see your comment block in the code, before. I haven't found - anywhere online - a way to set default_url_options for the entire application. There must be a way. But nobody illustrates it. Not even the rails site, that I've found.
I know how to set it for an individual class - I've done that, successfully. But I should be able to set that somewhere for the entire application - so I don't have to have multiple lines like
config.action_mailer.default_url_options = ...
ZencoderCommunicator.default_url_options = ...
That's bullshit, when they're all the same setting. I need something like
config.default_url_options = ...
The others can override that value, if need be.
Last comment:
But, adding the default_url_options value to that class works. Still a problem that there's no way for default_url_options to be an application-wide setting. You have to set it individually for every context. It's not like these values are going to change for the various models (right now). But they do change, based on the environment.