2

I got a missing template error when I tried to achieve a task using RJS.

All I want is to execute an RJS file on ajax call. But I am getting the following error.

ActionView::MissingTemplate (Missing template line_items/create,
application/create with {:handlers=>[:erb, :builder, :coffee],
:formats=>[:js, :html], :locale=>[:en, :en]}. Searched in:
  * "<MY APP PATH>/app/views"
):
  app/controllers/line_items_controller.rb:46:in `create'

But the create.js.rjs is present in the folder /views/line_items. You can see the handlers miss .rjs extension. I think thats causing the error.

If I change .rjs to .erb, it works and the content is executed as javascript and thus I need to modify the RJS functions to Javascript to return the contents of AJAX call.

Could you please explain how I can attain this using RJS? Please help.

Following is the versions of tools I use.

Ruby version  1.9.2 (i686-linux)
RubyGems version  1.8.10
Rack version  1.3
Rails version  3.1.0
JavaScript Runtime  Node.js (V8)
Active Record version  3.1.0
Action Pack version  3.1.0
Active Resource version  3.1.0
Action Mailer version  3.1.0
Active Support version  3.1.0

Thanks in advance.

Jithin
  • 2,594
  • 1
  • 22
  • 42

2 Answers2

2

in order to use RJS with Rails 3.1 you have to use the prototype-rails gem

Marian Theisen
  • 6,100
  • 29
  • 39
  • Yes, prototype-rails is installed. When I enter gems list, its listing prototype-rails. Please help – Jithin Oct 03 '11 at 13:16
0

Make sure prototype-rails gem is in bundler's production group. If you put it in the assets group it will not register the RJS template handler.

knoopx
  • 17,089
  • 7
  • 36
  • 41