我有一个应用程序,我有两个用户界面。Rails3和Respond_with问题
第一个用于普通用户,第二个用于iphone用户。
一切工作正常,直到我重构我的代码内控制器使用respond_with声明而不是respond_to。
该应用程序仍然为html界面(:format =>:html)工作,但不在iphone界面上(:format =>:iphone)。
在iphone上,当我执行以下操作(:index,:new,:edit,:show)时,它可以工作。
但是,当我做(:创建,:更新,:销毁),我得到错误,说模板没有找到(例如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是...而不是通过调用doc中指定的to_format方法。
是的,这可能是一个解决方案。但对我来说这还不够。 Iphone和html格式与他们应该回应的方式相同。如果可能,我正在寻找更好的方法。 Thx无论如何;) – Arkan 2011-01-14 02:54:01