1

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?

Dylan Markow
  • 123,080
  • 26
  • 284
  • 201
zishe
  • 10,665
  • 12
  • 64
  • 103
  • Can you post the code of the view that is submitting the form, so we can see how you're calling `posts/create`? – Dylan Markow Aug 18 '11 at 13:13
  • 1
    Oh, the problem was with rails.js file that i added, it's not working correctly. Now it works file, when i deleted it. Sorry, that i didn't mention this. So, the problem is solved, maybe i need to mark this somehow? – zishe Aug 19 '11 at 03:35

2 Answers2

3

Try adding the jquery-rails gem to your Gemfile.

zishe
  • 10,665
  • 12
  • 64
  • 103
1

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.

Dylan Markow
  • 123,080
  • 26
  • 284
  • 201