Your question doesn't make sense
The create action will respond to whatever mime types you have set up in your routes for the controller and whatever mime type responses you respond to in the controller.
If using RESTful routes (resources :some_controller_name) then you will get xml, html and json responses straight out of the box. Just remove the respond_to block or make sure you respond to json, xml and html
Now your create action will respond to json requests as well as html and xml requests
i mistake the cause of the error, it's not for the reassigning the variable!
in my app, i use Ajax and the CRUD all in index.html.erb.
the code of index
<% @entries.each do |entry| %>
<%= render entry %>
<% end %>
<div id="form"><%= render :partial => "form" %></div>
part codes of _form.html.erb
<%= form_for(@entry, :remote => true) do |f| %>
<%= f.label :name%><br />
<%= f.text_field :name%>
<%= file_field_tag :file%>
<%= f.submit %>
<% end %>
the code of new.js.erb
$("#form > form").replaceWith("<%= j render 'form' %>")
the code of create.js.erb
$("<%= j render @entry %>").appendTo("#entries").hide().fadeIn();
the code of update.js.erb
$("#<%= dom_id @entry %>").replaceWith("<%= j render @entry %>");
<% @entry = Entry.new %>
$("#form > form").replaceWith("<%= j render "form" %>");
there aren't any new.html.erb or show.html.erb,the result of all actions will be show in the index.html.erb
if the file_field_tag doesn't load file,the respond_to will works well and the input information just now will be show in the top of index.html.erb
(just i mentioned above the create action "Processing by EntriesController#create as JS")
but if load file, it will jump to the page (the show.html.erb that don't exists)as without ajax(create action "Processing by EntriesController#create as HTML")
about this case, how to deal with it?
Really bother you, forgive my ignorance question.
i am a rails rookie