Creating the basic Ruby on Rails app and deploying to Heroku
I have restarted some development with Ruby on Rails. Since the v7 is now out I have tried to create a new app following the tutorial from Heroku here: https://devcenter.heroku.com/articles/getting-started-with-rails6. This tutorial is prepared for Ruby on Rails 6, but it has worked perfectly fine for me. BTW, I am using a MacBook M1, in case that helps you.
The order of these two tasks is not critical, you may first create the repo, add a Github remote, and then follow the instructions to deploy it to Heroku.
The final result should look something like this, assuming you created an app locally in the myapp folder:
– Install the Guest Additions installed
– Configure the folder you would like to share. I recommend self-mount and permanent options
– Reboot the machine
– You may have read permission issues, then run the command sudo usermod -a -G vboxsf to give it rights
I was getting a “Too many redirect” problem in Apache, and went crazy to check where could be the origin of the problem. I got this error message from time to time, and this is very weird. Then there was a problem with the language multisite switcher, a great plugin that I highly recommend: https://wordpress.org/plugins/multisite-language-switcher/
Initially I thought it had to do with the “www” or canonical url, so I checked the DNS and so on. Then I thought it could be related to the WordPress multisite, since it has quite a complex url structure.
But finally I found the solution. The Multisite Language Switcher was generating urls of the type http://www.mysite.com/es (for exmample, for the Spanish version), and that causes a redirection error because it has to have the trailing slash “/” at the end, so the correct one would be http://www.mysite.com/es/
I went to the function that was generating the urls, the_msls (), and that led me to the file MslsOutput.php. In line 61 I added the slash:
$url = $mydata->get_permalink( $language )."/";
And now it works nicely!!!
I have to find out if there is a configuration in WordPress or Apache that automatically adds the “/” always. This was a random error, but it was provoking a toxic behaviour in Apache that is not acceptable.
Trailing Slash Problem
Description:
Every webmaster can sing a song about the problem of the trailing slash on URLs referencing directories. If they are missing, the server dumps an error, because if you say /~quux/foo instead of /~quux/foo/ then the server searches for a file named foo. And because this file is a directory it complains. Actually it tries to fix it itself in most of the cases, but sometimes this mechanism need to be emulated by you. For instance after you have done a lot of complicated URL rewritings to CGI scripts etc.
Solution:
The solution to this subtle problem is to let the server add the trailing slash automatically. To do this correctly we have to use an external redirect, so the browser correctly requests subsequent images etc. If we only did a internal rewrite, this would only work for the directory page, but would go wrong when any images are included into this page with relative URLs, because the browser would request an in-lined object. For instance, a request for image.gif in /~quux/foo/index.html would become /~quux/image.gif without the external redirect!
So, to do this trick we write:
RewriteEngine on
RewriteBase /~quux/
RewriteRule ^foo$ foo/ [R]
The crazy and lazy can even do the following in the top-level .htaccess file of their homedir. But notice that this creates some processing overhead.