Closed Rubioli closed 5 years ago
This seems like a host/asset_host configuration problem in production. Regardless, this definitely isn't a carrierwave-aws
issue.
Also, from your routes it looks like you are using ActiveStorage as well, which you would use instead of CarrierWave. If you're starting a new application and want to do it The Rails Way, you may want to use ActiveStorage instead.
@sorentwo Thanks a lot for your reply.
This might be out of line and I would appreciate if you could give me some pointers. Do you mean that since I use carrierwave
now, I wouldn't need to use ActiveStorage
if so would you please let me know how I can "turn it off"?
If you don't have the time to give me some pointers, I of course understand and already thank you for taking carrierwave-aws
from the problem-list
I'm suggesting that you use ActiveStorage if you have straight forward asset needs, since it is bundled with Rails. If you'd prefer to use CarrierWave then you would have to avoid loading rails globally and load individual packages instead.
Thanks a lot @sorentwo. appreciate you taking your time 💯
In my application I'm using
carrierwave
for image upload.My
CampaignsController
is a usualcreate action
Everything works fine in
development
, but inproduction
after submit/save things go wrong.By that I mean: In
development
when form is submitted, after save it goes tolocalhost:3000/campaigns/38
and my form is:action="campaigns/38"
.BUT
In production when form is submitted, after save, instead of going to
example.com/campaigns/38
, it goes toexample.com/campaigns/campaigns/38
and my form changes to:action="campaigns/campaigns/38"
.As you can see that extra
campaigns
is in the URL and I'm not sure why. It seems rails changed my root fromexample.com
toexample.com/campaigns
This is my
routes.rb
:This is my
ImageUploader
:My
carrierwave.rb
:My
Campaign
Model:This is my application version:
I've been testing with different things to see what exactly is the issue. I tested with
simple_form_for
,form_for
and even removed parts of theform
.Everything works as long as
= f.file_field :image
is not there. when I remove= f.file_field :image
from myform
everything works fine in all ENVs, but when I add it back, its thanProduction
has this strange behavior.I also change
redirect_to
torender
:format.html { render :show}
and when doing this, I dont getroute error
but ALL links in that pages (such as navigation links), changes toexample.com/campaigns/dashboard
,example.com/campaigns/users
and when I populateroot_path
in my view, it said:example.com/campagins
.When I get
route error
, in error page, I can some routes that I have never seen, been added to error page:Any help is appreciated and thanks in advance!