1

I have commendations/_create.html.erb which includes in a form -

<%= form_for(current_user.commendations.new(...), remote: true) do |f| %>
  <%=...

and in commendations_controller.rb

def create
...
  respond_to do |format|
    format.html { redirect_to :back }
    format.js
  end
end

but I'm getting the following error in the server log -

Completed 500 Internal Server Error in 7ms

ActionView::MissingTemplate (Missing template commendations/create, application/create with {:locale=>[:en], :formats=>[:js, :html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:
  * "/Users/dan/Documents/ROR/fic/app/views"
  * "/Users/dan/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/devise-3.4.1/app/views"):
  app/controllers/commendations_controller.rb:9:in `create'

I can't see where I'm going wrong - the remote: true should trigger format.js which in turn should reload the partial, no?

In routes.rb I have

 resources :commendations, only: [:create]
1
  • 1. where is the commendations/create is placed? 2. please issue touch Users/dan/Documents/ROR/fic/app/views/application/_create.html.erb and try again Commented Dec 1, 2014 at 15:14

1 Answer 1

2

You need a file called create.js within app/views/commendations/

And in create.js do:

$("#your_div").html( "<%= j render( :partial => 'commendations/your_partial') %>" );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.