Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby on rails - error accessing to public directory

I would like to ask you if is possible to show data, which I've to saved in /public/my_dir_for_data.

If I try to display an image from this directory, I get "Routing error". Probably when I would to saved the data to root of my application, e.g. /my_data, everything will be ok... but I like this structure of RoR application and I will be glad, if I could to use the directory in in /public...

Exist any way, how to do? (and simultaneously security?)

like image 754
el_quick Avatar asked Feb 24 '23 07:02

el_quick


1 Answers

If a file exists, rails won't go into the controller stack, if it can't find the file, it will assume that it's a dynamic action and go into the controller stack.

So, if a file exists at #{Rails.root}/public/directory/file.png and you navigate to domain.com/directory/file.png it should work render the file.

Are you sure all the directory and file names are the same on both sides?

like image 61
jesse reiss Avatar answered Mar 07 '23 02:03

jesse reiss