Alexander Kireyev
Alexander Kireyev

Reputation: 10825

Error in Rails 3.1 using js jQuery - "Template is missing"

I created app according to this post http://stjhimy.com/posts/7-creating-a-100-ajax-crud-using-rails-3-and-unobtrusive-javascript , but get an error:

Missing template posts/create, application/create with {:handlers=>[:erb, :builder, :coffee, :haml], :formats=>[:html], :locale=>[:en, :en]}. Searched in: * "/home/ember/Projects/test_app/app/views"

Maybe in Rails 3.1 actions render something by default. Besides, there no format js (:formats=>[:html]). But i can`t find any about this.

When i doing like this:

  respond_to do |format|
    format.js {render :content_type => 'text/javascript'}
  end

or without content_type - browser redirects to empty page. In this case:

  respond_to do |format|
    format.js
    format.html {render :nothing => true}
  end

browser shows the same empty page. How can i do that without any redirects?

Maybe it`s old method?

Upvotes: 1

Views: 1780

Answers (2)

user1673427
user1673427

Reputation: 74

Try adding the jquery-rails gem to your Gemfile.

Upvotes: 3

Dylan Markow
Dylan Markow

Reputation: 124409

Posting the answer you arrived at here so others will know:

With Rails 3.1, you no longer need to manually include the rails.js file in your application (or the jquery.js file for that matter). Having gem 'jquery-rails' in your Gemfile will already include these for you.

When you do manually include old pre-Rails 3.1 versions of these files, it could interfere with proper javascript/jQuery functionality.

Upvotes: 1

Related Questions