Why can't access rails application on production environment? - ruby-on-rails

When run the development mode, it works well:
$ rails s
But when the production mode:
$ RAILS_ENV=production rails s
And try to access it:
$ curl http://0.0.0.0:3000
Then message is:
Access denied.
There isn't any error log. Can't find what's the reason.

Make sure that you completed these steps before you ran rails s -e production.
bundle exec rake db:create RAILS_ENV=production
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake assets:precompile RAILS_ENV=production
then you can run: bundle exec rails s -e production

Related

Existing Redmine Project from Linux to Windows: Redmine is not migrated

This is the error I encounter during rake.
The Easy Project cannot start because the Redmine is not migrated!
Please run bundle exec rake db:migrate RAILS_ENV=production and than
bundle exec rake easyproject:install RAILS_ENV=production rake
aborted!
I try to run the command stated and it doesn't work.
Do I need to install something? Because the bundle install is successful.
I thought running the bundle install after giving me the project will do.
The first developer used Linux, but im on Windows.
Already resolved. I used these ffg commands:
bundle exec rake generate_secret_token
set RAILS_ENV=production
bundle exec rake db:migrate

rails4 rake assets precompile in production environment generate wrong javascript file

I'm working on deploy my rails application and I found that error always exists in my javascript file when I run RAILS_ENV=production bundle exec rails assets:precompile.But when I run rails assets:precompile to generate js file, it works well.Is there any differences between production and development in precompile phase? How can I solve this problem?
I think you don't have permission to generate compiled javascript file, to trace your error, run the following command:
RAILS_ENV=production bundle exec rails assets:precompile --trace
Solution of permission issue:
Try to run the command as sudo as the following:
sudo RAILS_ENV=production bundle exec rails assets:precompile --trace

Delayed Job in Rails 4 with Capistrano

I cant figure how to start Delayed Jobs on a dedicated Ubuntu server.
It works fine on my localhost but when I run on my server
sudo RAILS_ENV=production bin/delayed_job restart
I get
sudo: bin/delayed_job: command not found
On top of that, if I run the "rake jobs:work RAILS_ENV=production" command Im getting the following error:
PG::FeatureNotSupported: ERROR: SELECT FOR UPDATE/SHARE is not allowed in subqueries
Apparently theres an issue with my psql version.
Is there any way I can get the script to work? Any effective Capistrano recipes available? All ive found on the web are old recipes for Rails 3 and older versions of capistrano.
Thanks in advance.
EDIT:
I have already bundled install the daemons gem and generated "delayed_job:active_record" on my local machine, then proceded to cap deploy which bundle installed and migrated in the production server.
The bin/delayed_job file exists in the server yet it fails with command not found.
And add this to config/environment.rb:
ENV['RAILS_ENV'] ||= 'production'
Then at your production server:
RAILS_ENV=production rake db:migrate
RAILS_ENV=test production generate delayed_job:active_record && RAILS_ENV=production rake db:migrate
Now after you do that:
RAILS_ENV=production script/delayed_job start
As for Capistrano error you are facing, please try to add the command like:
run "cd #{current_path}; #{sudo} RACK_ENV=production bundle exec #{current_path}/bin/delayed_job start"
You must run this on target server:
bundle exec rails generate delayed_job

What does rake assets:precompile do without RAILS_ENV=production?

If I run the following commands and then visit a page it gives an error about routing failure on an asset.
rake assets:precompile
rails s -e production
However if I do the same after the following commands where I've added RAILS_ENV=production everything works.
rake assets:precompile RAILS_ENV=production
rails s -e production
What is rake assets:precompile doing when I omit RAILS_ENV=production that explains why it is not working properly?
It is precompiling the assets in your default environment, which is more than likely developement

error when run bundle exec rake db:migrate in windows?

when I run bundle exec rake db:migrate in windows CMD, it shows "ruby.exe is not recognized as an internal command...
but ruby.exe -v works fine..
what should I do now?

Resources