can't quite get this to work.
I have
class QuestionsController < ApplicationController
which renders a form
<%= form_for [question, QuestionResponse.new], remote: true, :html => {:multipart => true} do |f| %>
<%= f.text_area :text, cols: 30, rows: 8, %>
<%= f.file_field :image, id:"file4", title: "Attach Photo" %>
<%= f.submit "Reply", class: "btn-green" %>
<% end %>
than I have
QuestionResponsesController
def create
@question = #retrieve from params
@response = @question.response.new(params[:question_response])
@question.save!
end
This responds via javascript so I have
create.js
$("#<%= j "#{@question.id}_new_response"%>").before('<%= j render("response", response:@response)%>');
If I don't attach a file this works fine
When I attach I file I get Template is missing
Missing template question_responses/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :arb, :coffee]}.
Figured it was because rails decided it should respond to html where before it worked out .js response.
I tried:
- adding format: :js to form_for
- adding respond_to :js to QuestionResponsesController controller.
This didn't work it just ended up rendering the javascript in the browser rather than execute it.
Any ideas? Guessing it's simple.