rails/rails — Issue #3433: 3.1.1, html view has precedence over a js one in production
Author: masterkain
Created: 2011-10-25 16:34:23+00:00
State: open

I have two views for the same controller/action: home/index.html.haml home/index.js.coffee
I'm using the rails jquery adapter (see Gemfile below).

Then I make a normal ajax call (with data-remote=true) and in development mode rails renders the right view index.js.coffee.

In production mode however index.html.haml is always being called instead of the js one.

Assets are precompiled and I have no JS errors.
Browsers sends that right data and headers.

Rails itself says it's processing JS:

Started GET "/?page=2" for 151.64.233.122 at 2011-10-25 16:26:45 +0000
Processing by HomeController#index as JS
Parameters: {"page"=>"2"}
Rendered home/index.html.haml (172.3ms)
Completed 200 OK in 178ms (Views: 177.3ms)

But as you can see the wrong view is being rendered.

Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.1.1'

group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

Controller action:

def index
# Just render, please
end

I also tried with the classic respond_to/respond_with to no avail. All works in development but not in production.