Empty HTML in production - ruby-on-rails

Rails is returning blank HTML when running in production.
The tests I describe bellow are done with the following line: wget http://localhost:3000/login -O here.txt ; cat here.txt. I expect see some HTML being output after executing it.
On my server, I can see the HTML being rendered when I start rails in development mode, using the command rails s. I can see the following in the log:
Started GET "/login" for 127.0.0.1 at 2013-08-21 18:30:32 +0000
Processing by UserSessionsController#new as */*
Rendered user_sessions/_login.html.haml (59.5ms)
Rendered user_sessions/new.html.haml within layouts/application (62.8ms)
Compiled bootstrap-datepicker.css (0ms) (pid 8050)
Compiled application.css (4ms) (pid 8050)
Compiled bootstrap.min.css (0ms) (pid 8050)
# lots of Compiled lines
Rendered layouts/_navigation.html.haml (3.2ms)
Rendered layouts/_messages.html.haml (1.0ms)
Completed 200 OK in 1404ms (Views: 1395.6ms | ActiveRecord: 0.8ms)
When starting my application with RAILS_ENV=production rails s, doing the same request, I got the following on the log:
Started GET "/login" for 127.0.0.1 at 2013-08-21 18:30:52 +0000
Processing by UserSessionsController#new as */*
Rendered user_sessions/_login.html.haml (57.8ms)
Rendered user_sessions/new.html.haml within layouts/application (60.9ms)
Completed 200 OK in 69ms (ActiveRecord: 0.9ms)
But no HTML is output. What is happening? Why this is not working the same way that it does on development?
I use rails 3.2.13, and in this test it runs with WEBrick. I also am using RVM if that matters.
Update: Using the content of config/environments/development.rb on config/environments/production.rb does not fix the problem

The problem is that I was rescuing an exception on ApplicationController and not handling it properly by a logical error. The exception was not raised on development mode.

Related

Rails 4.2.6 disable MD5 for FIPS compliance

How does one disable MD5 and other non-FIPS compliant algorithms in Rails 4.2.6 and Ruby 2.2+?
Started GET "/" for ::1 at 2016-04-12 11:00:52 -0400 Processing by
Rails::WelcomeController#index as ​/​ Rendered
/usr/local/rvm/gems/ruby-2.2.4/gems/railties-4.2.6/lib/rails/templates/rails/welcome/index.html.erb
(0.9ms) Completed 200 OK in 20ms (Views: 6.5ms | ActiveRecord: 0.0ms)
md5_dgst.c(78): OpenSSL internal error, assertion failed: Digest MD5
forbidden in FIPS mode! Aborted (core dumped)
This has been addressed in Rails 5.2. See https://github.com/rails/rails/issues/31203. New apps should be compliant now by default and upgraded ones can use Rails.application.config.active_support.use_sha1_digests = true

Can't login with devise on heroku, all other environments work

I got an app that runs fine locally and on production (deployed with capistrano) and I'm trying to set up a staging environment which worked so far except for devise.
When I try to log in with working user credentials I get redirected to the root path but not logged in.
Logs:
Started POST "/login" for 95.91.228.167 at 2016-01-31 13:33:51 +0000
Processing by PagesController#index as HTML
Rendered shared/_sidebar.html.erb (0.2ms)
Completed 200 OK in 2.7ms (Views: 2.1ms | ActiveRecord: 0.0ms)
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"iHo8UfHuZ9S6GVbj3hAvfzqwo67FfZwZtdhwJ2qTk3Q=", "user"=>{"email"=>"xxx#xxx.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Einloggen"}
WARNING: Can't verify CSRF token authenticity
Redirected to http://xxx.herokuapp.com/
Completed 302 Found in 81.5ms (ActiveRecord: 0.0ms)
Started GET "/" for 95.91.228.167 at 2016-01-31 13:33:51 +0000
Rendered pages/index.html.erb within layouts/application (0.5ms)
I tried all solutions posted here like changing the domain in session_store and I updated devise to the most recent version.
Any ideas? If you need more information, please let me know.
As it turned out session_store.rb had domain: :all which I thought was fine. Once I changed it to xxx.herokuapp.com, it worked. Thanks!
--- Update 1 ---
Now that it works on heroku, it doesn't work on the production server anymore - obviously because of the wrong URL in session_store. What to do now?
--- Update 2 ---
Solved this by using environment variables

Unknown slow process of requests

The behaviour is: the browser hangs keep loading without any response back.
Please see the following log.
I, [2014-07-16T14:14:09.766062 #11713] INFO -- : Started GET "/somepage" for xxx.xxx.xxx.xxx at 2014-07-16 14:14:09 +0800
I, [2014-07-16T14:14:40.872411 #31111] INFO -- : Started GET "/" for yyy.yyy.yyy.yyy at 2014-07-16 14:14:40 +0800
I, [2014-07-16T14:14:40.874968 #31111] INFO -- : Processing by HomeController#index as */*
I, [2014-07-16T14:14:40.893189 #31111] INFO -- : Rendered ...
I, [2014-07-16T14:14:40.901553 #31111] INFO -- : Completed 200 OK in 26ms (Views: 22.5ms | ActiveRecord: 2.6ms)
... more other requests handled normally
I, [2014-07-16T14:29:35.395493 #11713] INFO -- : Processing by HomeController#somepage as HTML
I, [2014-07-16T14:29:35.403614 #11713] INFO -- : Rendered home/somepage.html.erb (1.5ms)
I, [2014-07-16T14:29:35.403762 #11713] INFO -- : Completed 200 OK in 8ms (Views: 5.0ms | ActiveRecord: 0.5ms)
In between the "Started GET ..." and "Processing by" logs, the rails app can handle other requests normally. However, the 2 logs (should be from the same request) have around 15mins gap.
Server: Apache with passenger
Database: Mysql using mysql2 adapter
I completely lost and have no clues what is the root cause....
I faced this similar kind of issue where the browser kept on loading with no logs in the log file.And what i found out was that we have mistakenly written find.all in one of our model as during testing it only had 1000 records as compared to production with more than 1 million records.so changing it to batch records/pagination resolved it.
...........Hope this might help you.

Can access production database from Rails console but not Rails App

When I try to login to my Devise app using the rails console on my production database, I can with no trouble, however I cannot when using my Rails App.
I launch my Rails Console with rails c -e production, from my home environment (not SSHing int it or anything) and then proceed to execute app.post('/users/sign_in', {"user"=>{"email"=>"email", "password"=>"password"}}), which succeeds with:
Started POST "/users/sign_in" for 127.0.0.1 at 2014-03-10 05:37:31 +0000
Started POST "/users/sign_in" for 127.0.0.1 at 2014-03-10 05:37:31 +0000
Processing by DeviseSessionsController#create as HTML
Processing by DeviseSessionsController#create as HTML
Parameters: {"user"=>{"email"=>"amar#sittr.co.nz", "password"=>"[FILTERED]"}}
Parameters: {"user"=>{"email"=>"amar#sittr.co.nz", "password"=>"[FILTERED]"}}
Redirected to http://www.example.com/dashboard
Redirected to http://www.example.com/dashboard
Completed 302 Found in 1830ms (ActiveRecord: 1426.3ms)
Completed 302 Found in 1830ms (ActiveRecord: 1426.3ms)
=> 302
From which I can then use app.get '/dashboard' which is a password protected page, and then succeeds with:
Started GET "/dashboard" for 127.0.0.1 at 2014-03-10 05:38:14 +0000
Started GET "/dashboard" for 127.0.0.1 at 2014-03-10 05:38:14 +0000
Processing by StaticPagesController#home as HTML
Processing by StaticPagesController#home as HTML
Rendered static_pages/home.html.haml within layouts/application (139.6ms)
Rendered static_pages/home.html.haml within layouts/application (139.6ms)
Completed 200 OK in 6370ms (Views: 686.2ms | ActiveRecord: 5087.6ms)
Completed 200 OK in 6370ms (Views: 686.2ms | ActiveRecord: 5087.6ms)
=> 200
This is all working as expected, except for when I try and go to the production site, and sign in with the same credentials, it gives me a 500 error Errno::ECONNREFUSEDdevise_sessions#create
Connection refused - connect(2) for "localhost" port 9200. What confuses me is that this says it is trying to connect to localhost which wouldn't make any sense. The following is my database.yml file (with the sensitive bits taken out):
production:
adapter: postgresql
database: db_name
pool: 5
timeout: 5000
host: rds.database.com
port: 5432
username: username
password: password
As you can see, I have set the port and host correctly. What am I doing wrong? Thanks in advance.

Can't open rails app, even if server is running

I've been developing a rails app with a VM and vagrant. Until yesterday, everything was working fine. However, when I tried to run the server and open the browser, it wasn't working. I tried on Chrome, Firefox and Safari, but the error persists on all three. I checked my dev logs, and this is what it says.
Yesterday's log:
Started GET "/" for 10.0.2.2 at 2013-12-11 06:38:31 +0000 Processing by HomeController#index as HTML Rendered home/index.html.erb within layouts/application (43.6ms) Completed 200 OK in 159ms (Views: 158.0ms | ActiveRecord: 0.0ms)
and today's log says:
Started GET "/" for 127.0.0.1 at 2013-12-12 19:02:04 +0000
[1m[36mActiveRecord::SchemaMigration Load (1.4ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
Processing by HomeController#index as */*
Rendered home/index.html.erb within layouts/application (212.7ms)
Completed 200 OK in 595ms (Views: 555.4ms | ActiveRecord: 0.0ms)
[1m[36mActiveRecord::SchemaMigration Load (1.5ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
[1m[35mActiveRecord::SchemaMigration Load (0.2ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
Could anyone explain why the address it's trying to connect to appears to be different? And what needs to be done in order to be able to connect to it again?
Thanks.

Resources