HaNdTriX HaNdTriX - 1 year ago 339
Ruby Question

Rails3 ActionView Template Handlers doesn't work on Production Server

I am using Rails 3.2.3 / Ruby 1.9.3p125 / jbuilder (0.4.0)

In my

folder i got a
when I test everything on my local machine with
rails s -e production
everything works fine.
The JSON gets rendered as espected.

But when I deploy to Ubuntu LTS (nginx/unicorn) I get the following Error Message:

ActionView::MissingTemplate (Missing template mycontroller/show, application/show with {:locale=>[:de, :en], :formats=>[:json], :handlers=>[:erb, :builder]}. Searched in:
* "/home/deployer/apps/myapp/releases/#############/app/views"

When I check on my server if the jbuilder gem is installed with
bundle show jbuilder
everything seems right.

weird is that the Error message does't show
:handlers=>[:erb, :builder, :jbuilder]

The jbuilder handler is obviously missing. But how do I solve the problem?

Edit: The Problem is not based on Jbuilder. I tried rabl and the same problem appears.

Does any one has a hint, how to debug this?

Here some more Information:


source 'https://rubygems.org'

gem 'rails', '3.2.3'
gem 'jquery-rails'
gem 'mysql2'
gem 'simple_form'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'bootstrap-sass', '2.0.2'

# Use unicorn as the app server
gem 'unicorn'

# Deploy with Capistrano
gem 'capistrano'

# for performance monitoring
gem 'newrelic_rpm'

# use asset pipline and flash
gem 'swf_fu', '~> 2.0'

gem 'geocoder'

# To use Jbuilder templates for JSON
gem 'jbuilder'


def show


show.json.jbuilder - file

json.(@map, :id)

Answer Source

Your jbuilder seems to be skipped.

Is jbuilder in your Gemfile.lock file?

cat Gemfile.lock | grep jbuilder

If it's missing:

RAILS_ENV=production bundle update jbuilder 

Is jbuilder loadable?

RAILS_ENV=production bundle exec rails console
> require 'jbuilder'
=> false  # this is false if jbuilder is pre-loaded

Can you build in the console?

> Jbuilder.encode{|j| j.foo :bar }
=> "{\"foo\":\"bar\"}"

Can you build in your controller action?

def the_method_you_are_testing
   raise Jbuilder.encode{|j| j.foo :bar }

Do you see the same error with a different server setup, such as Apache & Passenger instead of Nginx & Unicorn, or simply rails server?

rails server -e production

Do you get the same results if you change your server app from production to development?

rails server -e development

For RABL, can you try putting the RABL gem last in your Gemfile?

gem 'rails'
gem 'rabl'

Try registering immediately after requiring builder?

require 'tilt'
require 'rabl'
# ...
require 'builder'

Do you get the same results with RABL master?

gem 'rabl', :git => "git://github.com/nesquena/rabl.git" 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download