【问题标题】:Template is missing using Rails 4.2.4/React 0.14.6 and Devise 4.0/babel-core 6.7.4/webpack 1.12.14缺少使用 Rails 4.2.4/React 0.14.6 和 Devise 4.0/babel-core 6.7.4/webpack 1.12.14 的模板
【发布时间】:2016-04-23 22:16:00
【问题描述】:

我在我的测试应用中添加了 Devise 4.0(它是一种灵活的身份验证解决方案),它运行良好。但是,当我编写选项以更新索引视图中的配置文件时。我收到以下错误:

缺少模板配置文件/更新,应用程序/更新与 {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder]}。在以下位置搜索:*“/Users/jalanya/Documents/dev/ruby/twitter-clone/app/views”*“/Users/jalanya/.rvm/gems/ruby-2.2.2/gems/devise-4.0.0/应用程序/视图”

目前,我只有一个名为“index.html.erb”的文件夹视图/配置文件下方的视图。所以,我的问题是我应该为操作“profile#update”添加另一个视图模板吗?如果是这样,我该怎么做?

如果您也想测试,我在 github 中有我的测试应用程序。请在下面找到我目前拥有的文件。

routes.rb

Rails.application.routes.draw do

  get 'profile' => 'profile#index'
  post 'profile' => 'profile#update'

  devise_for :users
  root 'home#index'
end

profile_controller.rb

class ProfileController < ApplicationController
  before_action :authenticate_user!
  def index
  end
  def update
  end
end

views/profile/index.html.erb

<h2>Update profile</h2>
<%= form_tag "/profile" do %>
  <div class="row">
    <form class="col s12">
      <div class="row">
        <div class="input-field col s6">
          <input name="first_name" id="first_name" type="text" class="validate">
          <label for="first_name">First Name</label>
        </div>
        <div class="input-field col s6">
          <input name="last_name" id="last_name" type="text" class="validate">
          <label for="last_name">Last Name</label>
        </div>
        </div>
      <div class="row">
        <button type="submit" class="btn right">Save</button>
      </div>
    </form>
   </div>
<% end %>

请让我知道您的反馈。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-4 reactjs devise webpack


    【解决方案1】:

    您要么需要添加更新视图,要么需要在路由文件中注释掉该行。现在,您正在告诉路线关于不存在的视图。

    要添加它,您可以键入“rails generate view”或手动添加。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-18
      • 2018-11-06
      • 2016-02-04
      • 2016-04-01
      • 2016-04-26
      • 2015-09-08
      相关资源
      最近更新 更多