In rails 3.1 I was able to put a symbolic link to a directory of html pages in my public folder and it worked. Now in rails 3.2 it gives me a 404 not found page when I try to open any of those html files. What changed in rails 3.2 that now blocks symbolic links and how can I get around it?
To clarify, I have a friend who wants to save money by having his site hosted off mine. So when I deploy his site should be accessible at http://mysite.org/hissite/. He has an account on the same server as me so I just create a symbolic link to the directory hissite which is located in his account. I put this symbolic link in my public folder. Prior to upgrading to rails 3.2 this worked like a charm. I can use a hard directory but this would be on my account requiring him to send me updates which I would then have to post. This is a big hassle. It is important for me to allow him to host his content with my site as it is related content and helps bring more visitors to my site.
More details:
The problem is with my production site which is using passenger. In development, I tested it with a symlinked directory on my development machine and it worked fine. Hard links seem to work in production but then I have to update the directory whenever he adds new files which is a hassle.
Well I figured out a hack to get it to work but it is not what I would like. I wrote a capistrano task to link the files whenever I do a deployment. So my capistrano task looks like this.
namespace :accounts do
desc "Relink friend's site on each release"
task :relink_friends_site, :roles => :app do
run "mkdir -p #{release_path}/public/hissite"
run "cd #{release_path}/public/hissite && ln /home/hisaccount/hissite/index.html"
run "cd #{release_path}/public/hissite && ln /home/hisaccount/hissite/page2.html"
...
end
end
If anyone knows a better way to fix this please let me know. At least this way I don't have to relink the files myself foreach deployment.
Related
I'm relatively new to Rails as well as using PassengerPhusion. I am running an Ubuntu server on Azure, and have the demo app that Passenger provides working fine. I've even changed the text on the homepage.
My question is this:
In my directory, the file directory's name for the app is passenger-ruby-rails-demo and while I am experimenting, i am changing the name of the directory to something like passenger-ruby-rails-demo-test and it returns an error message when viewing fleetpro.cloudapp.net.
I've tried looking through files trying to figure out how this is routed but haven't had any luck. Is there a file within the Rails installation that is telling Passenger to be inside the specific passenger-ruby-rails-demo directory? Pretty newbish question, but it is really bothering me!
I'm not sure about how the naming convention works in regards to the root directory name of your app "passenger-ruby-rails-demo", but I believe the name of that directory is important to running your Rails app, and might have to do something with the name of the module in your config/application.rb file which is named after your Rails app.
There is a solution though: use gem rename.
Add gem rename to your Gemfile and run bundle install.
Then in your app's root directory, run this:
rails g rename:app_to New-Name
This will basically "clone" the app with your new name. You may have to check to make sure all your config files are present afterwards, but from my experience using it, it was a quick breeze. You will most definitely have to push the new renamed app back to git or Azure.
EDIT
As an example I renamed a Rails app to show what you could expect from the output after running the command:
The Rails app's name isn't the problem, it's the PassengerAppRoot switch you'll be using:
PassengerAppRoot /path/to/your/app
Rails doesn't actually care which folder it's put into, so renaming Rails won't fix your problem.
Renaming Rails only changes the internal class references within your application (things like Rails.application.name which have very subtle implications for your app).
In your Azure server, you'll need to locate either your .htaccess / httpd.conf / nginx.conf file, and change the PassengerAppRoot to your new path. This should resolve the issue.
I am working on an Opensourced project I want to create, deploying to a VPS.
I'm working with Rails 4 and Capistrano 3 on Ubuntu, both on the local machine and the server.
I have a configuration file named "application.yml" that includes basic information about the application, as a Google Analytics script, the application name, Mailer configurations and such.
I want to create a task that would rename "application.example.yml" to "application.yml" before Capistrano runs deploy:migrate.
I wrote the task below and put it in config/deploy.rb:
before "deploy:migrate", "configure:application"
namespace :configure do
task :application do
run "#{try_sudo} cp #{current_path}/config/application.example.yml #{current_path}/config/application.yml"
end
end
(I know cp copies the file but it also renames so it is fine.)
It does not seem to work. How can I rename "application.example.yml" before deploy:migrate runs?
GitHub Repository and deploy.rb
Also as I am moving forward with my App I seem to find more and more stuff I know little or nothing about, and would love it if someone experienced with Rails would be willing to become my "Mentor" by sharing with me his Skype (or any other communication service) so I could occasionally ask him my questions.
I'm new to RoR.
I was able to install Rails and host it in Webrick (Sample App with "Welcome" controller) in my windows.
Now i have a Unix Weblogic Server along with a dedicated domian.
After exporting the .WAR file using Warbler, i accessed the Oracle Admin Console from where i deployed the .WAR file in the dedicated domain. I did all this for the Sample app with only the Welcome controller in it.
But even after deploying the WAR file, on accessing the Domain along with the Port Number (:9002) i ended up with 404 file not found error On looking at the server logs,there wasn't any records relating to any error. The Application must have been deployed properly. I assume that i must have missed out on some basic configurations in the routes.rb or similar files before deploying. Can anyone Guess what are all the possibilities and if possible can anyone help me by pointing to any tuts that cover the Steps to be carried out for configuration before deployment. do i need to install both JRuby and Rails inside the server before depolyment?
I can't really guess with Eror 404 only.
You can try mapping your rails app rack config to a different base_uri.
All you need to do is wrap the existing 'run' command in a map block
try doing this in your rails 'config.ru' file:
map '/mydepartment' do
run Myapp::Application
end
Now when you 'rails server' the app should be at localhost:3000/mydepartment .
Not sure if this will give you the desired outcome, but worth a try.
One more thing you also add this to your config/environments/production.rb and config/environments/development.rb (if on production mode):
config.action_controller.asset_path = proc { |path| "/abc#{path}" }
otherwise when you call your helpers such as stylesheet_link_tag in your views, they will generate links without the "/abc".
Also, find some guides you may refer for good support.
JRubyOnRailsOnBEAWeblogic.
Use JRuby with JMX for Oracle WebLogic Server 11g
Let me know if it is not resolved.
I have a Ruby on Rails website which I have successfully tar the apps directory which included the current folder ect. Which I Wget to transfer the files over. The server I have moved to is setup to run Ruby on Rails but is there anything else I need todo to get it running?
Any commands via SSH?
My new server setups is Ubuntu 11.04 running ISPConfig 3 as the server admin.
Current the file are in the correct location with the correct permissions and owners. But all I'm getting is the default ISPConfig page.
(This is the default index page of your website.
This file may be deleted or overwritten without any difficulty. This is produced by the file index.html in the web directory.)
If anyone can point me in the right direction that would be great.
Have you tried creating a symbolic link on the server to the application something like
cd ~/public_html;
ln -s ~/rails-test-application/public rails3
http://www.site5.com/blog/programming/ruby-rails/how-to-deploy-phusion-passenger-to-a-subdirectory-routing-errors-and-restarting/20090414/
I have a few web services that require secure tokens/keys/passwords to be passed in. Where should I define these secure values for my rails app to see? I want the development keys in version control, but don't want the production keys in version control. How should I set this up? I'm new to rails.
You see the question properly.
Put your passwords and keys in some yml file excluded from version control.
Then on your production server, create the very same file and symlink your app to it every time you deploy.
EDIT.
Capistrano is almost made to fits these needs:
put your yml files in the shared folder
In your capistrano deploy.rbfile:
after 'deploy' do
run "ln -s #{shared_path}/database.yml #{release_path}/config/database.yml"
end
to work with yml files: http://railscasts.com/episodes/85-yaml-configuration-file
apneadiving is right, symlinking the files is a good idea. Another approach is to put the keys in the shell variables, accessible only to the user that runs the app. Then, in your rails app you'll have
login = ENV['SERVICE_LOGIN']
password = ENV['SERVICE_PASSWORD']
As of Rails 4.1.0, check out secrets.yml.