PDA

View Full Version : Ruby on Rails layouts/application.ext_json.erb possible mime type issue...



colvint
5 Mar 2008, 10:45 PM
Hey folks,

I'm using Ext JS 2.0.2 with Ruby on Rails and the ext scaffold plugin. I've been able to get a scaffold generated and working with a simple Post resource but have been getting an error in Firebug when adapting the scaffold pattern to my own resource "User". The error is:

<h1>Template is missing</h1><p>Missing layout layouts/application.ext_json.erb in view path C:/Documents and Settings/guest/demo/app/views</p>

It almost looks like the ext_json mime type alias isn't aliasing or something, and therefore Rails is still looking for a layout for the returned json? I've tried everything from adding a mime type alias to mime_types.rb to all sorts of variations in both the view and controller to no avail. Help!

In case it helps, here's the code in the controller action in question. Though this code is essentially the same as what the generator spits out but maybe I'm missing something.


class AdminController < ApplicationController

before_filter :login_required

def dashboard
end

def users
respond_to do |format|
format.html # index.html.erb (no data required)
format.ext_json { render :json => find_users.to_ext_json(:class => :user, :count => User.count) }
end
end

protected

def find_user
@user = User.find(params[:id])
end

def find_users
pagination_state = update_pagination_state_with_params!(:user)
@users = User.find(:all, options_from_pagination_state(pagination_state).merge(options_from_search(:user)))
end
end

colvint
6 Mar 2008, 12:25 AM
Had nothing to do with ext js or the scaffold plugin. I was simply performing a GET to the wrong URI.