简体   繁体   中英

Rails How to fix Missing mobile template?

i'm trying to update the user information when on mobile but rails log show:

someone know why this happen on mobile mode?

Missing template users/update, application/update with {: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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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