Search code examples
ruby-on-railsnginxunicorn

Rails application works in development but is empty in production


My Rails 4 application runs in development mode, but at production I only see an empty page.

It's running Unicorn with Nginx in a CentOS 7 VPS.

Any hint what I need?

unicorn_rails -c config/unicorn.rb -D

Rails development

unicorn_rails -c config/unicorn.rb -D -E production

Rails production

The logs of Nginx, Unicorn and Rails don't show any errors.

Rake routes
[root@mycentos my_app]# rake routes

   Prefix Verb   URI Pattern               Controller#Action
    blogs GET    /blogs(.:format)          blogs#index
          POST   /blogs(.:format)          blogs#create
 new_blog GET    /blogs/new(.:format)      blogs#new
edit_blog GET    /blogs/:id/edit(.:format) blogs#edit
     blog GET    /blogs/:id(.:format)      blogs#show
          PATCH  /blogs/:id(.:format)      blogs#update
          PUT    /blogs/:id(.:format)      blogs#update
          DELETE /blogs/:id(.:format)      blogs#destroy

In development I can access normally to any route, even it shows me error messages when the route doesn't exist. But in production, is always blank. Works well in development - always blank in production


Solution

  • After investigating a lot, the problem was that there wasn't the secret key for production. So I had to generate it running rake secret and pasting it in config/secrets.yml.