Rails 2 public folder: No route matches assets - ruby-on-rails

I am working on a legacy Ruby on Rails application which is running under Ruby 1.9 and Rails 2.3.18.
I am serving the application through Apache with Passenger.
I am getting errors in the production.log which indicate that there is something wrong with how Rails or the web server is treating the public folder, e.g.
ActionController::RoutingError (No route matches "/javascripts/picnet.table.filter.min.js" with {:method=>:get})
All the required assets which are causing the errors are in the application public folder. Note that this is under Rails 2 not Rails 3 or 4.
My Apache host entry for the application looks like this:
<VirtualHost 127.0.0.1:443>
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile "/Users/evanbrown/Documents/apache-keys/server.crt"
SSLCertificateKeyFile "/Users/evanbrown/Documents/apache-keys/server.key"
ServerAdmin me#localhost
DocumentRoot "/Users/evanbrown/Documents/bl-app/public"
ServerName blapp.localhost
ServerAlias blapp.localhost
ErrorLog "/private/var/log/apache2/localhost-error.log"
PassengerRuby "/Users/evanbrown/.rvm/gems/ruby-1.9.3-p547#rails2/wrappers/ruby"
CustomLog "/private/var/log/apache2/localhost-access.log" common
<Directory "/Users/evanbrown/Documents/bl-app/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Options -MultiViews
PassengerAppEnv production
</Directory>
</VirtualHost>
The application is being served correctly by Passenger but since all the stylesheets and Javascripts in the public folder are causing routing errors, the output is all wrong.
I have read lots of posts that state that a misconfigured config.serve_static_assets can cause these problems but this seems to be for Rails 3 only as there is no option serve_static_assets under config in Rails 2.
My public folder is owned by the Apache user and group, which I understand is _www:_www under OS X.
-rwxrwxrwx 1 _www _www 947 5 Nov 11:20 404.html
-rwxrwxrwx 1 _www _www 930 5 Nov 11:20 422.html
-rwxrwxrwx 1 _www _www 948 5 Nov 11:20 500.html
-rwxrwxrwx 1 _www _www 0 5 Nov 11:20 favicon.ico
-rwxrwxrwx 1 _www _www 14571 5 Nov 11:20 favicon.png
drwxrwxrwx 4 _www _www 136 5 Nov 11:20 images
drwxrwxrwx 11 _www _www 374 5 Nov 11:20 javascripts
-rwxrwxrwx 1 _www _www 204 5 Nov 11:20 robots.txt
drwxrwxrwx 4 _www _www 136 5 Nov 11:20 stylesheets
Can anyone help me to find out what the solution to this problem is? Many thanks for your help.

Related

Remote server log production.log is empty

Issue: log/production.rb file exists but is empty on production Rails 4.2 environment.
App root and permissions:
drwxrwxr-x 2 deploy deploy 4096 Mar 7 14:59 .
drwxrwxr-x 21 deploy deploy 4096 Mar 7 04:16 ..
-rw-rw-r-- 1 deploy deploy 0 Feb 6 17:13 .git_keep
-rw-rw-r-- 1 deploy deploy 95833941 Mar 9 05:16 newrelic_agent.log
-rwxrwxrwx 1 deploy deploy 80 Mar 9 01:16 production.log
-rw------- 1 deploy deploy 129287 Mar 7 08:24 production.searchd.log
-rw------- 1 deploy deploy 93957 Mar 9 05:06 production.searchd.query.log
-rw------- 1 deploy deploy 5 Feb 7 10:37 production.sphinx.pid
config/environments/production.rb
# If you have no front-end server that supports something like X-Sendfile,
# just comment this out and Rails will serve the files
config.log_level = :info
# Basic log config, for calls to Rails.logger.<level> { <message> }
config.logger = Logger.new('log/production.log')
# Formats log entries into: LEVEL MESSAGE
# Heroku adds to this timestamp and worker/dyno id, so datetime can be stripped
config.logger.formatter = ->(severity, datetime, progname, msg) { "#{severity} #{msg}\n" }
# Lograge config, overrides default instrumentation for logging ActionController and ActionView logging
config.lograge.enabled = true
Help please. Thank you for advance

Rails App (Redmine) not served via Apache

I have a website, under which I wanted to install redmine(rails application) so that I could access redmine as a subdirectory (http://mywebsite.foobar.com/redmine). I have installed redmine, and I can access it locally (lynx http://localhost:3000), but when I try to access it via a browser by typing its address, I get the list of files. How can I make the application accessible? I do have passenger installed. My virtualhost file is as follows:
1 <VirtualHost *:80>
2 ServerName mywebsite.foobar.com
3 ServerAlias www.mywebsite.foobar.com
4 ServerAdmin admin#foobar.com
5 Redirect permanent / https://mywebsite.foobar.com/
6
7 DocumentRoot /path/to/www/
8 ReadmeName README.html
9 IndexOptions SuppressHTMLPreamble
10
11 <Directory "/path/to/www">
12 Options Indexes FollowSymLinks
13 Order allow,deny
14 Allow from all
15 → Require all granted
16 IndexIgnore ..
17 IndexIgnore README.html
18 </Directory>
19
20 RailsEnv production
21 → → RewriteEngine on
22 → → → Alias /redmine /path/to/www/redmine/public/
23 → → → <Directory "/path/to/www/redmine/public/">
24 → → → → Order allow,deny
25 → → → → allow from all
26 → → Options +Indexes +FollowSymLinks -MultiViews +ExecCGI
27 → → Require all granted
28 → → → </Directory>
29
30
31
32 Include aliases.conf
33 Include /etc/apache2/foobar/security.conf
34 </VirtualHost>
Also my https virtualhost looks like this:
1 <VirtualHost *:443>
2 SSLEngine On
3 SSLCertificateFile /etc/apache2/ssl/foobar.crt
4 SSLCertificateKeyFile /etc/apache2/ssl/foobar.key
5 SSLCertificateChainFile /etc/apache2/ssl/gd_bundle.crt
6
7 ServerName mywebsite.foobar.com
8 ServerAlias www.mywebsite.foobar.com
9 ServerAdmin admin#foobar.com
10 UseCanonicalName Off
11
12 DocumentRoot /path/to/www/
13 RailsEnv Production
14 RewriteEngine on
15
16 <Directory "/path/to/www/">
17 Require all granted
18 </Directory>
19
20
21 Alias /redmine /path/to/www/redmine/public
22
23 <Location /redmine>
24 PassengerBaseURI /redmine
25 PassengerAppRoot /path/to/www/redmine/public/
26 </Location>
27
28 <Directory "/path/to/www/redmine/public">
29 Order allow,deny
30 allow from all
31 Options +Indexes +FollowSymLinks -MultiViews +ExecCGI
32 Require all granted
33 </Directory>
34
35 Include /etc/apache2/foobar/security.conf
36
37
38 </VirtualHost>
P.S: The website itself is served as a virtualhost, so redmine would be a directory under virtual host.
Ok. So I found my solution on passenger documentation: I basically had to change the options. The related options look like:
39 Alias /redmine /path/to/www/redmine/public/
40 <Location /redmine>
41 PassengerBaseURI /redmine
42 PassengerAppRoot /path/to/www/redmine
43 </Location>
44 <Directory /path/to/www/redmine/public>
45 Allow from all
46 Options +Indexes +FollowSymLinks -MultiViews +ExecCGI
47 Require all granted
48 </Directory>

Rails 4 SQLite3::ReadOnlyException: attempt to write a readonly database

I keep receiving the error SQLite3::ReadOnlyException: attempt to write a readonly database: UPDATE "users" SET "current_sign_in_at" = ?, "sign_in_count" = ?, "updated_at" = ? WHERE "users"."id" = ? when trying to sign into my Rails 4 app which uses the devise gem.
I figured it has something to do with permissions on the dev db so checked out the permissions of the dir first, it has a + tacked onto the end which after some googling still couldn't figure out what it's doing.
-rw-r--r-- 1 a36971 staff 2.1K 24 Jan 20:16 Gemfile
-rw-r--r-- 1 a36971 staff 5.7K 24 Jan 20:16 Gemfile.lock
-rw-r--r-- 1 a36971 staff 47B 7 Jan 22:31 README.md
-rw-r--r--+ 1 root staff 249B 7 Jan 19:57 Rakefile
drwxr-xr-x+ 8 root staff 272B 7 Jan 19:57 app/
drwxr-xr-x+ 7 root staff 238B 7 Jan 19:57 bin/
drwxr-xr-x+ 13 root staff 442B 22 Jan 20:14 config/
-rw-r--r--+ 1 root staff 153B 7 Jan 19:57 config.ru
drwxr-xr-x+ 8 root staff 272B 26 Jan 10:28 db/
drwxr-xr-x+ 4 root staff 136B 7 Jan 19:57 lib/
drwxr-xr-x+ 5 root staff 170B 8 Jan 15:51 log/
drwxr-xr-x+ 7 root staff 238B 7 Jan 19:57 public/
drwxr-xr-x 7 a36971 staff 238B 17 Jan 22:38 spec/
drwxr-xr-x+ 9 root staff 306B 7 Jan 19:57 test/
drwxr-xr-x+ 6 root staff 204B 7 Jan 20:19 tmp/
drwxr-xr-x+ 3 root staff 102B 7 Jan 19:57 vendor/
After cd ing into the db dir you can see there's nothing wrong with the permissions on the db itself:
-rw-r--r-- 1 a36971 staff 44K 26 Jan 09:30 development.sqlite3
drwxr-xr-x 5 a36971 staff 170B 22 Jan 20:14 migrate/
-rw-r--r-- 1 a36971 staff 2.2K 22 Jan 20:14 schema.rb
-rw-r--r-- 1 a36971 staff 1.2K 25 Jan 23:22 seeds.rb
-rw-r--r-- 1 a36971 staff 44K 26 Jan 09:23 test.sqlite3
So my questions are:
a) why is it unable to write to the db when there doesn't appear to be anything wrong with the permissions themselves
b) what does the + mean on mac os?
a) why is it unable to write to the db when there doesn't appear to be anything wrong with the permissions themselves
My best guess is that the db/ directory is owned by the root user, whereas the db/*.sqlite3 files are owned by user a36971. It may be necessary for the db/ directory to also be owned by user a36971.
Try changing the owner from root to a36971 for the db directory:
sudo chown a36971 db
b) what does the + mean on mac os?
+ sign means there are additional permission details not displayed by the default output from ls -l. Try running ls -le to see the details (source: http://tech.enekochan.com/en/2014/05/29/plus-and-at-symbols-listing-file-permissions-in-mac-os-x/).
Got the same error after running rails db:reset
Restarting the local server fixed my problem

liferay page layout thumbnails not showing up

The issue is that I am not able to see thumbnails of the Page layouts. I am working on Liferay Portal EE 6.1.20.
When I go to Manage -> Page Layout, I cannot see the thumbnails.
Few things
I am not using OOB Liferay, it is a custom solution where Liferay is bundled as a custom portal solution
This thing works fine in Liferay OOB, so there must be some configuration issue
I tried to debug with Firebug and it is able to fetch the image from the URL specified.
The context path is changed from / to /portal
The generated image URL is like this /portal/layouttpl/custom/1_2_columns_ii.png. This is also not accessible from the browser itself.
The other URLS like /portal/html or /portal/wap/ working fine. Only from /portal/layouttpl does not allow to access static resources.
Any Idea?
It might be worth checking the file permissions of the images. In my Liferay development enviroment, I have all of my images set to 777:
user#ubuntu:/usr/liferay/tomcat/webapps/ROOT/layouttpl/custom$ ll *.png
-rwxrwxrwx 1 root root 1801 Apr 2 2012 1_2_1_columns.png*
-rwxrwxrwx 1 root root 1798 Apr 2 2012 1_2_columns_ii.png*
-rwxrwxrwx 1 root root 1793 Apr 2 2012 1_2_columns_i.png*
-rwxrwxrwx 1 root root 1425 Apr 2 2012 1_column.png*
-rwxrwxrwx 1 root root 1923 Apr 2 2012 2_2_columns.png*
-rwxrwxrwx 1 root root 1718 Apr 2 2012 2_columns_iii.png*
-rwxrwxrwx 1 root root 1735 Apr 2 2012 2_columns_ii.png*
-rwxrwxrwx 1 root root 1618 Apr 2 2012 2_columns_i.png*
-rwxrwxrwx 1 root root 1852 Apr 2 2012 3_columns.png*
-rwxrwxrwx 1 root root 1740 Apr 2 2012 freeform.png*

Redmine 2.0.1 - missing CSS?

The version that I'm using:
Redmine version 2.0.1.stable
Ruby version 1.8.7 (i386-linux)
Rails version 3.2.3
Environment production
Database adapter MySQL
The strange thing is after pressing Ctrl+F5 a few times, I will get something like this:
I can't find any interesting in the production.log:
Started GET "/admin/info" for 192.168.3.40 at Sat Jun 23 21:14:50 +0700 2012
Processing by AdminController#info as HTML
Rendered admin/info.html.erb within layouts/admin (2.2ms)
Rendered admin/_menu.html.erb (7.8ms)
Rendered layouts/base.html.erb (72.9ms)
Completed 200 OK in 93ms (Views: 79.1ms | ActiveRecord: 8.3ms)
/etc/httpd/conf.d/passenger.conf
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12
PassengerRuby /usr/bin/ruby
/etc/httpd/conf.d/vhost.conf
<VirtualHost *:80>
ServerName redmine.domain.vn
ServerAdmin quanta#domain.vn
DocumentRoot /var/www/html/redmine/public/
RailsBaseURI /
ErrorLog logs/redmine.error_log
<Directory "/var/www/html/redmine/public/">
Options -MultiViews
Order allow,deny
Allow from all
AllowOverride none
Satisfy Any
</Directory>
</VirtualHost>
There is no .htaccess file in the public folder that might cause the problems with passenger:
ls -la /var/www/html/redmine/public/
-rw-rw-r-- 1 apache apache 485 May 28 14:25 404.html
-rw-rw-r-- 1 apache apache 674 May 28 14:25 500.html
-rwxr-xr-x 1 apache apache 473 Jun 2 11:34 dispatch.fcgi
-rwxrwxr-x 1 apache apache 473 May 28 14:25 dispatch.fcgi.example
-rw-rw-r-- 1 apache apache 7886 May 28 14:25 favicon.ico
drwxrwxr-x 2 apache apache 4096 May 28 14:25 help
-rw-rw-r-- 1 apache apache 1441 May 28 14:25 htaccess.fcgi.example
drwxrwxr-x 4 apache apache 4096 May 28 14:25 images
-rw-r--r-- 1 apache apache 20 Jun 23 18:59 info.php
drwxrwxr-x 4 apache apache 4096 May 28 14:25 javascripts
drwxrwxr-x 2 apache apache 4096 May 28 14:25 stylesheets
drwxrwxr-x 4 apache apache 4096 May 28 14:25 themes
Any thoughts?
UPDATE Sat Jun 23 22:50:44 ICT 2012
The source when missing CSS:
<link href="/themes/classic/stylesheets/I.application.css,q1338189946.pagespeed.cf.0ULULhmylO.css" media="all" rel="stylesheet" type="text/css"/>
<script src="/javascripts/prototype.js,q1338189946.pagespeed.jm.ix8Kb1Gh8H.js" type="text/javascript"></script>
<script src="/javascripts/effects.js,q1338189946.pagespeed.jm.2gOWX1ohLv.js" type="text/javascript"></script>
<script src="/javascripts/dragdrop.js,q1338189946.pagespeed.jm.vpl0THRgUC.js" type="text/javascript"></script>
<script src="/javascripts/controls.js,q1338189946.pagespeed.jm.-zBskbSR2S.js" type="text/javascript"></script>
<script src="/javascripts/rails.js,q1338189946.pagespeed.jm.unwctb3Jeq.js" type="text/javascript"></script>
<script src="/javascripts/application.js,q1338189946.pagespeed.jm.Su1eFnevwF.js" type="text/javascript"></script>
and this shows the page with CSS:
<link href="/themes/classic/stylesheets/application.css?1338189946" media="all" rel="stylesheet" type="text/css"/>
<script src="/javascripts/prototype.js?1338189946" type="text/javascript"></script>
<script src="/javascripts/effects.js?1338189946" type="text/javascript"></script>
<script src="/javascripts/dragdrop.js?1338189946" type="text/javascript"></script>
<script src="/javascripts/controls.js?1338189946" type="text/javascript"></script>
<script src="/javascripts/rails.js?1338189946" type="text/javascript"></script>
<script src="/javascripts/application.js?1338189946" type="text/javascript"></script>
Where these weird characters that cause the wrong href and src path come from?
It seems that the culprit is... mod_pagespeed. I see the below error when turning on the Firebug:
"NetworkError: 500 Internal Server Error - http://redmine.domain.vn/javascripts/prototype.js,q1338189946.pagespeed.jm.ix8Kb1Gh8H.js"
Disable it and now Redmine is working fine:
<VirtualHost *:80>
ServerName redmine.domain.vn
ServerAdmin quanta#domain.vn
DocumentRoot /var/www/html/redmine/public/
RailsBaseURI /
ErrorLog logs/redmine.error_log
ModPagespeed off
<Directory "/var/www/html/redmine/public/">
Options -MultiViews
Order allow,deny
Allow from all
AllowOverride none
Satisfy Any
</Directory>
</VirtualHost>

Resources