简体   繁体   English

Rails如何修复丢失的手机模板?

[英]Rails How to fix Missing mobile template?

i'm trying to update the user information when on mobile but rails log show: 我正在尝试在移动设备上更新用户信息,但Rails日志显示:

someone know why this happen on mobile mode? 有人知道为什么在移动模式下会发生这种情况吗?

Missing template users/update, application/update with {:locale=>[:"en"], :formats=>[:mobile], :handlers=>[:erb, :builder, :coffee]}. 缺少模板用户/更新,带有{:locale => [:: en“] 、: formats => [:mobile] 、: handlers => [:erb,:builder,:coffee]}的应用程序/更新。 Searched in: 在以下位置搜索:

def update
    @user = User.find(params[:id])
    respond_to do |format|
      format.html do
        @states = State.all
        @cities = City.where('state_id = ?', State.first.id)
        if @user.update_attributes(params[:user])
          redirect_to(action: :edit, id: @user, only_path: true, format: :html)
          flash[:notice] = 'updated'

        else
          render :edit
        end
      end
      format.json do
        @user.update_attributes(params[:user])
        render nothing: true
      end
    end
  end

You have format.html do and format.json do but you don't have a format.mobile do block. 你有format.html doformat.json do ,但你没有format.mobile do块。

Since the html and json blocks aren't executed, the code falls through and the default for any action is to render the format with the name of the action, so you're in the action update therefore rails by default looks for a view update.html.erb or update.html.haml 由于未执行html和json块,因此代码会掉线,并且任何操作的默认设置都是使用操作名称来呈现格式,因此您处于操作update因此Rails默认情况下会查找视图update.html.erbupdate.html.haml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM