Answer the question
In order to leave comments, you need to log in
Rails ActionView::MissingTemplate how to fix error?
Hello
From time to time an error occurs in the project:
ActionView::MissingTemplate: Missing template mobile_synchronization/orders, application/orders with {:locale=>[:ru], :formats=>[:json], :handlers=>[:erb, :builder]}. Searched in:
* "/var/www/mss/releases/20140717080253/app/views"
* "/var/www/mss/shared/bundle/ruby/1.9.1/gems/twitter-bootstrap-rails-2.2.6/app/views"
* "/var/www/mss/shared/bundle/ruby/1.9.1/gems/devise-2.2.4/app/views"
* "/var/www/mss/shared/bundle/ruby/1.9.1/gems/kaminari-0.14.1/app/views"
POST http://server.com/synchronization/orders.json
respond_to do |format|
if @order.save
@responce = JSON code: 100, description: 'created successfully'
format.json { render json: @responce, status: :created, location: @order }
else
@responce = JSON code: 200, description: 'the data format is not valid'
format.json { render json: @responce, status: :unprocessable_entity }
end
end
Answer the question
In order to leave comments, you need to log in
I'm no rails expert, but it seems that every controller should have a view by default. Maybe it's worth creating an empty view and rendering it with an option layout: false # нивелируем добавление layout
. When I gave html on ajax request, I did something similar, though my view was not empty.
Check this case:
maybe users right click on server.com/synchronization/orders.json link and select "open in new tab"
Try to write this code in the controller to always force JSON rendering:respond_to :json
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question