【问题标题】:Rails How to fix Missing mobile template?Rails 如何修复缺少的移动模板?
【发布时间】:2017-10-13 00:23:26
【问题描述】:

我正在尝试在移动设备上更新用户信息,但 Rails 日志显示:

有人知道为什么在移动模式下会发生这种情况吗?

缺少模板用户/更新,应用程序/更新与 {:locale=>[:"en"], :formats=>[:mobile], :handlers=>[:erb, :builder, :咖啡]}。搜索:

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

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3


    【解决方案1】:

    你有 format.html doformat.json do 但你没有 format.mobile do 块。

    由于没有执行 html 和 json 块,因此代码会失败,并且任何操作的默认设置是使用操作名称呈现格式,因此您在操作 update 因此默认情况下为 rails寻找视图update.html.erbupdate.html.haml

    【讨论】:

    • @SteveTurczynyes 谢谢你,因为 dropzone js,我不得不这样做。所以,只是添加一个手机和平板电脑块!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-26
    • 2015-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多