ruby-on-rails – 在呈现简单的json头响应时获取“ActionView ::
发布时间:2020-12-17 03:02:37 所属栏目:百科 来源:网络整理
导读:在我的一个控制器中,我有这个代码: 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 returnend 但是,当json请求到来时,我收到
在我的一个控制器中,我有这个代码:
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 但是,当json请求到来时,我收到此错误: 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" 这真让我感到困惑,因为我在许多其他控制器中都有类似的代码而且它实际上正在工作……控制器只需要用html头响应,它不需要模板. 解决方法
而不是“并返回”删除那些,并在整个respond_to块之后放回.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ruby-on-rails – Rails:为什么在rake任务中调用to_a字符串
- reactos操作系统实现(1)
- Objective-c – iOS9 – UITableViewCellContentView覆盖了
- [cocos2dx]交叉编译android工程报错:Unable to add x:\
- flex菜单同步选择单选“综合应用”
- XML简介之DTD约束的相关实例
- 基础篇章:关于 React Native 之 Picker 组件的讲解
- c# – 资源部分中的WPF DataContextProxy
- 关于setting的string.xml里的product属性的有关问题
- Oracle dmp文件损坏恢复案例