In one of my controllers, I have this code:
respond_to do |format|
format.html{ redirect_to :me, :flash => {:error => t('quest_histories.misc.bad_request')}} and return
format.json{ head :method_not_allowed } and return
end
BUT, when a json request comes, i get this error:
ActionView::MissingTemplate (Missing template quest_histories/index, application/index with {:locale=>[:en], :formats=>[:json], :handlers=>[:erb, :builder, :coffee]}. Searched in:
* "/var/www/PMAC_RoR/app/views"
This really confuses me, because I have similar code in many other controllers and it’s actually working… the controller just have to respond with a html header, it shouldn’t need a template.
Instead of “and return” remove those, and put the return after the whole respond_to block.