Rails 4 images in a shared folder do not load when developing Apache

I am new to rails. I am working on an example social media application. I managed to upload the user profile image manually (by copying the image uploaded to / tmp / image to the public folder - public / images / tmp / image) and saved the path to db as url_avatar.

In the profile view, I used

<%= image_tag(@userinfo.avatar_url, :alt=>"Avatar image")%>

and image acquisition when working on the rails server.

But after that, I deployed the application in apache with the passenger in the development environment, installing RailsEnv development . After this, the images do not load. I tried switching to myip: 80 / public / images / tmp / image , and it gives a routing error .

After searching the Internet, I found that adding config.serve_static_assets = trueto production.rb would solve the problem during production. But I have nothing to use, because he also stated that static files will work in development by default. To confirm the problem again, I started the rails server and opened localhost: 3000 / profile, the image is there and the image in myip: 80 / profile did not work.

So I need to add any other configuration. Or I should not do it that way.

+4
source share
2 answers

Finally, I got a solution for my problem. Just share it here.

- . temp . temp . , . , , 403 .

FileUtils.chmod 775, target

. .

+3

config.serve_static_assets = true , , Apache.

Apache, .

tutorial , Apache Passenger, , .

, , -. myip: 80/public/images/tmp/image . .

+1

All Articles