Если тип известен вызывающей стороне, существует лучший, более быстрый путь, чем использование Активатора. CreateInstance: можно вместо этого использовать универсальное ограничение на метод, который указывает, что имеет конструктора без параметров по умолчанию.
Выполнение его этот путь безопасен с точки зрения типов и не требует отражения.
T CreateType<T>() where T : new()
{
return new T();
}
asset.url
returns the URL to the file. This is usually /system/classname/xx/xx/style/filename.ext
. You'd put this in an image_tag
.
You want asset.path
. It returns the full path to the file, which will usually be something like /home/username/railsapp/public/system/classname/xx/xx/style/filename.ext
HTH.
Typically root_url
should provide this.
File.read is expecting a file path, not a url though. If you are generating the images, you should call the image generating code and return the bytes of the generated image instead of calling File.read(…)