I am having a big problem with my rails app which I am trying to deploy on a VPS. I have some files in the rails app public/ folder such as public/javascripts/home-menu.js and also I use Sprocket to precompiled into public/assets.
In my production.rb setting
config.serve_static_assets = false #i want to serve through Apache not rails
config.assets.compress = true
config.assets.compile = false
config.assets.digest = true
While the rails app is serving fine, all files on public/ directory cannot be served. The error is shown below.
Routing Error
No route matches [GET] "/assets/application-fbbe68455909a54f6d39e01d3ab38d34.js"
Try running rake routes for more information on available routes.
I reckon that it is something wrong with Apache setting so I went in to check. Having CPanel, Apache setting is set automatically. I added the below to "/usr/local/apache/conf/userdata/std/2/gadgettr/mydomain.com/.conf"*
<Directory /home/gadgettr/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
#Options FollowSymLinks
#AllowOverride None
#Order allow,deny
#Allow from all
</Directory>
And in the http.conf
<VirtualHost 103.15.232.XXX:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /home/gadgettr/public_html
ServerAdmin [email protected]
UseCanonicalName Off
## User gadgettr # Needed for Cpanel::ApacheConf
UserDir enabled gadgettr
<IfModule mod_suphp.c>
suPHP_UserGroup gadgettr gadgettr
</IfModule>
<IfModule !mod_disable_suexec.c>
<IfModule !mod_ruid2.c>
SuexecUserGroup gadgettr gadgettr
</IfModule>
</IfModule>
<IfModule mod_ruid2.c>
RMode config
RUidGid gadgettr gadgettr
</IfModule>
<IfModule itk.c>
# For more information on MPM ITK, please read:
# http://mpm-itk.sesse.net/
AssignUserID gadgettr gadgettr
</IfModule>
ScriptAlias /cgi-bin/ /home/gadgettr/public_html/cgi-bin/
Include "/usr/local/apache/conf/userdata/std/2/gadgettr/gadgettrader.sg/*.conf"
</VirtualHost>
I cannot change the DocumentRoot /home/gadgettr/public_html so I create an alias ln -s /home/gadgettr/public /home/gadgettr/public_html
However I cannot solve my problem and still get the same routing error. Why is Apache not serving my static file?
Spent an entire day debugging this... Really need all the help I can have! Appreciate your help!