【发布时间】:2011-01-13 14:04:54
【问题描述】:
我有一个应用程序,上面有两个用户界面。
第一个是普通用户,第二个是iphone用户。
一切正常,直到我在控制器中重构我的代码以使用respond_with 声明性而不是respond_to。
该应用程序仍然适用于 html 界面(:format => :html),但不适用于 iphone 界面(:format => :iphone)。
在 iphone 上,当我执行以下操作(:index、:new、:edit、:show)时,它会起作用。
但是当我这样做(:create,:update,:destroy)时,我收到错误消息说找不到模板(例如create.iphone.haml)。
在我的控制器上我有
respond_to :html, :iphone
然后例如,编辑和更新操作
def edit
@refund = Refund.find(params[:id])
respond_with(@refund)
end
def update
@refund = Refund.find(params[:id])
if @refund.update_attributes(params[:refund])
flash[:notice] = 'Refund was successfully updated.'
end
respond_with(@refund, :location => project_refunds_path(@project))
end
事实上,我希望 :iphone 格式被处理为 :html 是 ... 而不是通过调用 to_format 方法,因为它在 doc 中指定。
【问题讨论】:
标签: ruby-on-rails-3 respond-to respond-with