Ray Shih
Ray Shih

Reputation: 933

assets_host in carrierwave config

Since I am currently using nginx to serve public/uploads only in subdomain assets, and also I am using the client side template(eco) to render the image (so I cannot use image_tag or image_url helper method provided by rails), I need to set the model.image_url (which provided by carrierwave) to return url with same domain.

Here is what I had tried: (in config/initializer/carrierwave.rb)

    CarrierWave.configuration do |config|
            config.assets_host = "http://assets.lvh.me:3000"
    end

But when I try this setting then the rails popup an error message:

    undefined method `assets_host=' for CarrierWave::Uploader::Base:Class (NoMethodError)

Since the README of carrierwave has this description of setting but only in fog section, so I'm wondering that is this function only work while using fog? Or did I miss anything?

Thanks for help

Upvotes: 1

Views: 5599

Answers (2)

glampr
glampr

Reputation: 379

In later versions this changed to

CarrierWave.configure do |config|
  ...
end

Upvotes: 1

MarsZ Chen
MarsZ Chen

Reputation: 436

should use asset_host ( version > 0.7.0)

see chnage commit on github
https://github.com/jnicklas/carrierwave/commit/7046c93d6b23cffef9f171a5f7f0dd14267a7057#lib/carrierwave/uploader/configuration.rb

CarrierWave.configuration do |config|
  config.asset_host = "http://assets.lvh.me:3000"
end

Upvotes: 7

Related Questions